From 88305e1b9f4592a2ab129015ce409fcc16613ebb Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 28 Jun 2017 14:52:12 +0100 Subject: Add support for version 2 of the GNU Build Attribute note specification. * objcopy.c (merge_gnu_build_notes): Add support for version 2 notes. * readelf.c (print_gnu_build_attribute_name): Likewise. --- binutils/readelf.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'binutils/readelf.c') diff --git a/binutils/readelf.c b/binutils/readelf.c index edfe652..df7e8c3 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -481,7 +481,7 @@ print_symbol (signed int width, const char *symbol) if (width < 0) { - /* Keep the width positive. This also helps. */ + /* Keep the width positive. This helps the code below. */ width = - width; extra_padding = TRUE; } @@ -17185,7 +17185,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) const char * expected_types; const char * name = pnote->namedata; const char * text; - int left; + signed int left; if (name == NULL || pnote->namesz < 2) { @@ -17194,6 +17194,16 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) return FALSE; } + left = 20; + + /* Version 2 of the spec adds a "GA" prefix to the name field. */ + if (name[0] == 'G' && name[1] == 'A') + { + printf ("GA"); + name += 2; + left -= 2; + } + switch ((name_type = * name)) { case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: @@ -17201,6 +17211,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: printf ("%c", * name); + left --; break; default: error (_("unrecognised attribute type in name field: %d\n"), name_type); @@ -17208,7 +17219,6 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) return FALSE; } - left = 19; ++ name; text = NULL; @@ -17268,6 +17278,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) else { static char tmpbuf [128]; + error (_("unrecognised byte in name field: %d\n"), * name); sprintf (tmpbuf, _(""), * name); text = tmpbuf; @@ -17278,10 +17289,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) } if (text) - { - printf ("%s", text); - left -= strlen (text); - } + left -= printf ("%s", text); if (strchr (expected_types, name_type) == NULL) warn (_("attribute does not have an expected type (%c)\n"), name_type); -- cgit v1.1