Module Name: src Committed By: christos Date: Sat Dec 13 18:32:59 UTC 2014
Modified Files: src/external/gpl3/binutils/dist/binutils: readelf.c src/external/gpl3/binutils/dist/binutils/doc: readelf.1 src/external/gpl3/binutils/dist/include/elf: common.h Log Message: - Add -f to allow processing non-plain files. - Align NetBSD note printing properly - Add handling of "PaX" notes correctly. Perhaps we should rename them to "NetBSD" now. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/external/gpl3/binutils/dist/binutils/readelf.c cvs rdiff -u -r1.4 -r1.5 \ src/external/gpl3/binutils/dist/binutils/doc/readelf.1 cvs rdiff -u -r1.5 -r1.6 src/external/gpl3/binutils/dist/include/elf/common.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/binutils/dist/binutils/readelf.c diff -u src/external/gpl3/binutils/dist/binutils/readelf.c:1.13 src/external/gpl3/binutils/dist/binutils/readelf.c:1.14 --- src/external/gpl3/binutils/dist/binutils/readelf.c:1.13 Fri Sep 19 13:19:53 2014 +++ src/external/gpl3/binutils/dist/binutils/readelf.c Sat Dec 13 13:32:59 2014 @@ -185,6 +185,7 @@ static Elf_Internal_Phdr * program_heade static Elf_Internal_Dyn * dynamic_section; static Elf_Internal_Shdr * symtab_shndx_hdr; static int show_name; +static int do_special_files; static int do_dynamic; static int do_syms; static int do_dyn_syms; @@ -3201,6 +3202,7 @@ static struct option options[] = {"relocs", no_argument, 0, 'r'}, {"notes", no_argument, 0, 'n'}, {"dynamic", no_argument, 0, 'd'}, + {"special-files", no_argument, 0, 'f'}, {"arch-specific", no_argument, 0, 'A'}, {"version-info", no_argument, 0, 'V'}, {"use-dynamic", no_argument, 0, 'D'}, @@ -3246,6 +3248,7 @@ usage (FILE * stream) -r --relocs Display the relocations (if present)\n\ -u --unwind Display the unwind info (if present)\n\ -d --dynamic Display the dynamic section (if present)\n\ + -f --special-files Process non-plain files too\n\ -V --version-info Display the version sections (if present)\n\ -A --arch-specific Display architecture specific information (if any)\n\ -c --archive-index Display the symbol/file index in an archive\n\ @@ -3365,7 +3368,7 @@ parse_args (int argc, char ** argv) usage (stderr); while ((c = getopt_long - (argc, argv, "ADHINR:SVWacdeghi:lnp:rstuvw::x:", options, NULL)) != EOF) + (argc, argv, "ADHINR:SVWacdefghi:lnp:rstuvw::x:", options, NULL)) != EOF) { switch (c) { @@ -3415,6 +3418,9 @@ parse_args (int argc, char ** argv) case 'u': do_unwind++; break; + case 'f': + do_special_files++; + break; case 'h': do_header++; break; @@ -12706,14 +12712,24 @@ process_netbsd_elf_note (Elf_Internal_No (version / 10000) % 100 > 26 ? "Z" : "", 'A' + (version / 10000) % 26); else - printf (" NetBSD\t0x%08lx\tIDENT %u (%u.%u.%u)\n", pnote->descsz, + printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u.%u)\n", pnote->descsz, version, version / 100000000, (version / 1000000) % 100, (version / 100) % 100); return 1; case NT_NETBSD_MARCH: - printf (" NetBSD\t0x%08lx\tMARCH <%s>\n", pnote->descsz, + printf (" NetBSD\t\t0x%08lx\tMARCH <%s>\n", pnote->descsz, pnote->descdata); return 1; + case NT_NETBSD_PAX: + version = byte_get((unsigned char *)pnote->descdata, sizeof(version)); + printf (" NetBSD\t\t0x%08lx\tPaX <%s%s%s%s%s%s>\n", pnote->descsz, + ((version & NT_NETBSD_PAX_MPROTECT) ? "+mprotect" : ""), + ((version & NT_NETBSD_PAX_NOMPROTECT) ? "-mprotect" : ""), + ((version & NT_NETBSD_PAX_GUARD) ? "+guard" : ""), + ((version & NT_NETBSD_PAX_NOGUARD) ? "-guard" : ""), + ((version & NT_NETBSD_PAX_ASLR) ? "+ASLR" : ""), + ((version & NT_NETBSD_PAX_NOASLR) ? "-ASLR" : "")); + return 1; default: break; } @@ -13050,6 +13066,10 @@ process_note (Elf_Internal_Note * pnote) /* NetBSD-specific core file notes. */ return process_netbsd_elf_note (pnote); + else if (const_strneq (pnote->namedata, "PaX")) + /* NetBSD-specific core file notes. */ + return process_netbsd_elf_note (pnote); + else if (const_strneq (pnote->namedata, "NetBSD-CORE")) /* NetBSD-specific core file notes. */ nt = get_netbsd_elfcore_note_type (pnote->type); @@ -13789,7 +13809,7 @@ process_file (char * file_name) return 1; } - if (! S_ISREG (statbuf.st_mode)) + if (!do_special_files && ! S_ISREG (statbuf.st_mode)) { error (_("'%s' is not an ordinary file\n"), file_name); return 1; Index: src/external/gpl3/binutils/dist/binutils/doc/readelf.1 diff -u src/external/gpl3/binutils/dist/binutils/doc/readelf.1:1.4 src/external/gpl3/binutils/dist/binutils/doc/readelf.1:1.5 --- src/external/gpl3/binutils/dist/binutils/doc/readelf.1:1.4 Sun Sep 29 10:03:30 2013 +++ src/external/gpl3/binutils/dist/binutils/doc/readelf.1 Sat Dec 13 13:32:59 2014 @@ -146,6 +146,7 @@ readelf [\fB\-a\fR|\fB\-\-all\fR] [\fB\-r\fR|\fB\-\-relocs\fR] [\fB\-u\fR|\fB\-\-unwind\fR] [\fB\-d\fR|\fB\-\-dynamic\fR] + [\fB\-f\fR|\fB\-\-special-files\fR] [\fB\-V\fR|\fB\-\-version\-info\fR] [\fB\-A\fR|\fB\-\-arch\-specific\fR] [\fB\-D\fR|\fB\-\-use\-dynamic\fR] @@ -282,6 +283,13 @@ the unwind sections for \s-1IA64\s0 \s-1 .IX Item "--dynamic" .PD Displays the contents of the file's dynamic section, if it has one. +.IP "\fB\-f\fR" 4 +.IX Item "-f" +.PD 0 +.IP "\fB\-\-special-files\fR" 4 +.IX Item "--special-files" +.PD +Allows processing of non-plain files. .IP "\fB\-V\fR" 4 .IX Item "-V" .PD 0 Index: src/external/gpl3/binutils/dist/include/elf/common.h diff -u src/external/gpl3/binutils/dist/include/elf/common.h:1.5 src/external/gpl3/binutils/dist/include/elf/common.h:1.6 --- src/external/gpl3/binutils/dist/include/elf/common.h:1.5 Fri Sep 19 13:19:53 2014 +++ src/external/gpl3/binutils/dist/include/elf/common.h Sat Dec 13 13:32:59 2014 @@ -607,6 +607,15 @@ #define NT_NETBSD_IDENT 1 #define NT_NETBSD_MARCH 5 +/* Values for NetBSD .note.netbsd.ident notes. Note name is "PaX". */ +#define NT_NETBSD_PAX 3 +#define NT_NETBSD_PAX_MPROTECT 0x01 /* Force enable Mprotect */ +#define NT_NETBSD_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ +#define NT_NETBSD_PAX_GUARD 0x04 /* Force enable Segvguard */ +#define NT_NETBSD_PAX_NOGUARD 0x08 /* Force disable Servguard */ +#define NT_NETBSD_PAX_ASLR 0x10 /* Force enable ASLR */ +#define NT_NETBSD_PAX_NOASLR 0x20 /* Force disable ASLR */ + /* Values for OpenBSD .note.openbsd.ident notes. Note name is "OpenBSD". */ #define NT_OPENBSD_IDENT 1