From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 8231E3858C62 for ; Wed, 21 Sep 2022 06:24:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8231E3858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x435.google.com with SMTP id b75so4931272pfb.7 for ; Tue, 20 Sep 2022 23:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date; bh=i+Zj4ALMNiH0Ltu4qAAyoJksoeaGwckuhNJ7eBFgA6c=; b=FZFXyc/VrkRNq4eocV6OAAuE22pCxhTiOTsV2JCbtSaD+wnSytuctFgGg79XoeRYgJ oyoL9ef24im5VmWxyMkMhebUUcApJ8Neq2VZFxSpy5T5lBNJunCyp2ptM302z60oW2F3 12G0EE8le8Q0r/OkP2NZLeiywRn+OrwjrU8rSlTYiAhTrvgfljnxa6usJTni/ZfKm5Qf mCH0KElaB4DvWUAaUQpfMFKfCcQJLlyh4E1UiBeD0bL6s2jkVXE8ukbS+iBMzMm9QfUb FTrgI9iksUBSZNIf57kunEqGX+ttLu3nrZ/PRfQiOAfygYCnKFnNYlBv09C+N4h53TWu GEWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=i+Zj4ALMNiH0Ltu4qAAyoJksoeaGwckuhNJ7eBFgA6c=; b=MQ74qigQ1Hr5AFWuDRfm5Gg/5z2dZT8lWbsjwUsq3nJoXGeYTGf23Zi2DAcaf1EPqm FlEiUQQJ1mi4JKPSSvKTtLM4EfxQXlK86g3lWZ39NeeAsm8LfwlJiqgKO2rLe4RUEPNb ugCAL5VyO6ls7lRjYHi7uzPqSWHLtT3BEX29zOZwacHDh2OhcEl3Rfug8FLTbPsf3/LC FYA7NuTm9sh4Pb+L6syOFiD5+ug4dY+dK7Bgx8lZSz2YjErRSUvvyFeEEFAs24RZ7NvP xGaSEwhuhnOjtMblFDXNcqvA2qopFsrVB2KFqpZMhlJ4ajPFcrbScxnZG8lSzSYLDWCP MBDA== X-Gm-Message-State: ACrzQf3WE8eFuLHlulmzYzFsApXZf4BU3ZHf4UNeLYUHd/rYKiSxOIpt Bf+uMv8nsXSEoKOfVd4HQoEXGKPdXgE= X-Google-Smtp-Source: AMsMyM5ezlPnqRqONZ+zYFttXGthdRSEKJ7YPzp/iweU/5l91nLhn80WiQX//AzGVfzqFA1RY6ZKbw== X-Received: by 2002:a63:e617:0:b0:435:144e:4482 with SMTP id g23-20020a63e617000000b00435144e4482mr23902641pgh.434.1663741440470; Tue, 20 Sep 2022 23:24:00 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:9a23:33bb:ab6a:2a17]) by smtp.gmail.com with ESMTPSA id q33-20020a631f61000000b0041c30def5e8sm1045351pgm.33.2022.09.20.23.23.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 23:24:00 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 8169C1142E0B; Wed, 21 Sep 2022 15:53:57 +0930 (ACST) Date: Wed, 21 Sep 2022 15:53:57 +0930 From: Alan Modra To: binutils@sourceware.org Subject: dwarf2.c: mangle_style Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: non_mangled incorrectly returned "true" for Ada. Correct that, and add a few more non-mangled entries. Return a value suitable for passing to cplus_demangle to control demangling. There is quite a high chance this still isn't correct. Corrections welcome. * dwarf2.c: Include demangle.h. (mangle_style): Rename from non_mangled. Return DMGL_* value to suit lang. Adjust all callers. diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index e7c12c3e9de..138cdbb00bb 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -32,6 +32,7 @@ #include "sysdep.h" #include "bfd.h" #include "libiberty.h" +#include "demangle.h" #include "libbfd.h" #include "elf-bfd.h" #include "dwarf2.h" @@ -1711,31 +1712,52 @@ read_attribute (struct attribute * attr, return info_ptr; } -/* Return whether DW_AT_name will return the same as DW_AT_linkage_name - for a function. */ +/* Return mangling style given LANG. */ -static bool -non_mangled (int lang) +static int +mangle_style (int lang) { switch (lang) { + case DW_LANG_Ada83: + case DW_LANG_Ada95: + return DMGL_GNAT; + + case DW_LANG_C_plus_plus: + case DW_LANG_C_plus_plus_03: + case DW_LANG_C_plus_plus_11: + case DW_LANG_C_plus_plus_14: + return DMGL_GNU_V3; + + case DW_LANG_Java: + return DMGL_JAVA; + + case DW_LANG_D: + return DMGL_DLANG; + + case DW_LANG_Rust: + case DW_LANG_Rust_old: + return DMGL_RUST; + default: - return false; + return DMGL_AUTO; case DW_LANG_C89: case DW_LANG_C: - case DW_LANG_Ada83: case DW_LANG_Cobol74: case DW_LANG_Cobol85: case DW_LANG_Fortran77: case DW_LANG_Pascal83: - case DW_LANG_C99: - case DW_LANG_Ada95: case DW_LANG_PLI: + case DW_LANG_C99: case DW_LANG_UPC: case DW_LANG_C11: case DW_LANG_Mips_Assembler: - return true; + case DW_LANG_Upc: + case DW_LANG_HP_Basic91: + case DW_LANG_HP_IMacro: + case DW_LANG_HP_Assembler: + return 0; } } @@ -3599,7 +3621,7 @@ find_abstract_instance (struct comp_unit *unit, if (name == NULL && is_str_form (&attr)) { name = attr.u.str; - if (non_mangled (unit->lang)) + if (mangle_style (unit->lang) == 0) *is_linkage = true; } break; @@ -4095,7 +4117,7 @@ scan_unit_for_symbols (struct comp_unit *unit) if (func->name == NULL && is_str_form (&attr)) { func->name = attr.u.str; - if (non_mangled (unit->lang)) + if (mangle_style (unit->lang) == 0) func->is_linkage = true; } break; -- Alan Modra Australia Development Lab, IBM