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