Try harder to find the correct symbol to associate with OPEN GNU BUILD notes.

* readelf.c (print_gnu_build_attribute_description): Move symbol
	printing code to...
	(print_symbol_for_build_attribute): New function.  ...here.
	Add to find the best symbol to associate with an OPEN note.
	Add code to cache the symbol table and string table, so that they
	are not loaded every time a note is displayed.
	* testsuite/binutils-all/note-2-32.s: Add a function symbol.
	* testsuite/binutils-all/note-2-64.s: Likewise.
	* testsuite/binutils-all/note-2-32.d: Update expected note output.
	* testsuite/binutils-all/note-2-64.d: Likewise.
This commit is contained in:
Nick Clifton 2017-03-14 12:57:09 +00:00
parent 0efcde634d
commit c799a79d66
6 changed files with 167 additions and 98 deletions

View file

@ -13,5 +13,5 @@
[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
[ ]+\$<version>1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\)
[ ]+!<stack prot>false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10.
[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies from offset 0x10.
[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\)
#...

View file

@ -39,6 +39,8 @@ note1.s:
.global note2.s
note2.s:
.type func1, STT_FUNC
func1:
.word 0x100
.pushsection .gnu.build.attributes, "0x100000", %note

View file

@ -13,5 +13,5 @@
[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
[ ]+\$<version>1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\)
[ ]+!<stack prot>false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10.
[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies from offset 0x10.
[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\)
#...

View file

@ -39,8 +39,11 @@ note1.s:
.global note2.s
note2.s:
.global func1
.type func1, STT_FUNC
func1:
.word 0x100
.pushsection .gnu.build.attributes, "0x100000", %note
.dc.l 4
.dc.l 8