This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Commit: Add support for displaying and merging GNU_BUILD_NOTEs
- From: Nick Clifton <nickc at redhat dot com>
- To: Jiong Wang <jiong dot wang at foss dot arm dot com>, binutils at sourceware dot org
- Date: Thu, 2 Mar 2017 10:54:51 +0000
- Subject: Re: Commit: Add support for displaying and merging GNU_BUILD_NOTEs
- Authentication-results: sourceware.org; auth=none
- References: <8737ex1cez.fsf@redhat.com> <e277d22f-c1ef-a10f-6fd8-70232640a659@foss.arm.com>
Hi Jiong,
> I am seeing this new test failed on AArch64 cross and native check-binutils.
> AArch64 is outputing
> $<version>1 0x00000008 NT_GNU_BUILD_ATTRIBUTE_OPEN Applies from offset 0x100 (file: $d)
Doh! Sorry - I missed this in my testing.
I am applying the attached patch to fix this problem.
Cheers
Nick
binutils/ChangeLog
2017-03-02 Nick Clifton <nickc@redhat.com>
* readelf.c (print_gnu_build_attribute_description): Use global
symbols for OPEN attributes if at all possible.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 5cccccb..3bae045 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -16585,6 +16585,7 @@ print_gnu_build_attribute_description (Elf_Internal_Note * pnote,
for (i = 0; i < pnote->descsz; i += desc_size)
{
+ Elf_Internal_Sym * saved_sym = NULL;
Elf_Internal_Sym * sym;
unsigned long offset;
@@ -16609,8 +16610,19 @@ print_gnu_build_attribute_description (Elf_Internal_Note * pnote,
{
if (strtab[sym->st_name] == 0)
continue;
+
if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN)
- printf (_(" (file: %s)"), strtab + sym->st_name);
+ {
+ /* For OPEN attributes we prefer GLOBAL symbols, if there
+ is one that matches. But keep a record of a matching
+ LOCAL symbol, just in case that is all that we can find. */
+ if (ELF_ST_BIND (sym->st_info) == STB_LOCAL)
+ {
+ saved_sym = sym;
+ continue;
+ }
+ printf (_(" (file: %s)"), strtab + sym->st_name);
+ }
else if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
continue;
else
@@ -16618,8 +16630,14 @@ print_gnu_build_attribute_description (Elf_Internal_Note * pnote,
break;
}
}
+
if (sym == symtab + nsyms)
- printf (_(" (<symbol name unknown>)"));
+ {
+ if (saved_sym)
+ printf (_(" (file: %s)"), strtab + saved_sym->st_name);
+ else
+ printf (_(" (<symbol name unknown>)"));
+ }
}
printf ("\n");