aboutsummaryrefslogtreecommitdiff
path: root/binutils/readelf.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2017-03-21 11:48:57 +0000
committerNick Clifton <nickc@redhat.com>2017-03-21 11:48:57 +0000
commit75d7d2986cf896fac8f0690db68ebc552e0b0339 (patch)
tree9fc34a0303c8c4e6f180af7c9d507b1113bac406 /binutils/readelf.c
parent5badf10a18af78c57dd4ce8e6a6ead7f46e1a878 (diff)
downloadgdb-75d7d2986cf896fac8f0690db68ebc552e0b0339.zip
gdb-75d7d2986cf896fac8f0690db68ebc552e0b0339.tar.gz
gdb-75d7d2986cf896fac8f0690db68ebc552e0b0339.tar.bz2
Update support for GNU BUILD notes so that version notes can contain extra information, and stack protection notes can contain numeric values.
* readelf.c (print_gnu_build_attribute_name): Allow stack protection notes to contain numeric values. Use a colon rather than a space to separate a string name from its values. Decode the numeric value of a stack protection note. * objcopy.c (merge_gnu_build_notes): Allow version notes to contain extra text after the protocol version number.
Diffstat (limited to 'binutils/readelf.c')
-rw-r--r--binutils/readelf.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 8b1d924..6ede239 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -16809,7 +16809,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
break;
case GNU_BUILD_ATTRIBUTE_STACK_PROT:
text = _("<stack prot>");
- expected_types = "!+";
+ expected_types = "!+*";
++ name;
break;
case GNU_BUILD_ATTRIBUTE_RELRO:
@@ -16850,7 +16850,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
if (len > left && ! do_wide)
len = left;
- printf ("%.*s ", len, name);
+ printf ("%.*s:", len, name);
left -= len;
name += len;
}
@@ -16871,7 +16871,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
}
if (strchr (expected_types, name_type) == NULL)
- warn (_("attribute does not have the expected type\n"));
+ warn (_("attribute does not have an expected type (%c)\n"), name_type);
if ((unsigned long)(name - pnote->namedata) > pnote->namesz)
{
@@ -16888,9 +16888,10 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
{
case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC:
{
- unsigned int bytes = pnote->namesz - (name - pnote->namedata);
- unsigned long val = 0;
- unsigned int shift = 0;
+ unsigned int bytes = pnote->namesz - (name - pnote->namedata);
+ unsigned long val = 0;
+ unsigned int shift = 0;
+ char * decoded = NULL;
while (bytes --)
{
@@ -16900,33 +16901,44 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote)
shift += 8;
}
- if (name_attribute == GNU_BUILD_ATTRIBUTE_PIC)
+ switch (name_attribute)
{
- char * pic_type = NULL;
-
+ case GNU_BUILD_ATTRIBUTE_PIC:
switch (val)
{
- case 0: pic_type = "static"; break;
- case 1: pic_type = "pic"; break;
- case 2: pic_type = "PIC"; break;
- case 3: pic_type = "pie"; break;
- case 4: pic_type = "PIE"; break;
+ case 0: decoded = "static"; break;
+ case 1: decoded = "pic"; break;
+ case 2: decoded = "PIC"; break;
+ case 3: decoded = "pie"; break;
+ case 4: decoded = "PIE"; break;
+ default: break;
}
-
- if (pic_type != NULL)
+ break;
+ case GNU_BUILD_ATTRIBUTE_STACK_PROT:
+ switch (val)
{
- if (do_wide)
- left -= printf ("%s", pic_type);
- else
- left -= printf ("%-.*s", left, pic_type);
- break;
+ /* Based upon the SPCT_FLAG_xxx enum values in gcc/cfgexpand.c. */
+ case 0: decoded = "off"; break;
+ case 1: decoded = "on"; break;
+ case 2: decoded = "all"; break;
+ case 3: decoded = "strong"; break;
+ case 4: decoded = "explicit"; break;
+ default: break;
}
+ break;
+ default:
+ break;
}
- if (do_wide)
- left -= printf ("0x%lx", val);
+ if (decoded != NULL)
+ print_symbol (-left, decoded);
else
- left -= printf ("0x%-.*lx", left, val);
+ {
+ if (do_wide)
+ left -= printf ("0x%lx", val);
+ else
+ left -= printf ("0x%-.*lx", left, val);
+ }
}
break;
case GNU_BUILD_ATTRIBUTE_TYPE_STRING: