1# -*- coding: utf-8 -*- 2# Copyright 2018 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6"""Check whether the compile unit is not built by gcc.""" 7 8 9from allowlist import is_allowlisted 10 11 12def not_by_gcc(dso_path, producer, comp_path): 13 """Check whether the compile unit is not built by gcc. 14 15 Args: 16 dso_path: path to the elf/dso. 17 producer: DW_AT_producer contains the compiler command line. 18 comp_path: DW_AT_comp_dir + DW_AT_name. 19 20 Returns: 21 False if compiled by gcc otherwise True. 22 """ 23 if is_allowlisted("ngcc_comp_path", comp_path): 24 return True 25 26 if is_allowlisted("ngcc_dso_path", dso_path): 27 return True 28 29 return "GNU C" not in producer 30