Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl3/binutils/dist - Add -f to allow processing non...



details:   https://anonhg.NetBSD.org/src/rev/a89f048e0dd1
branches:  trunk
changeset: 805028:a89f048e0dd1
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Dec 13 18:32:59 2014 +0000

description:
- 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.

diffstat:

 external/gpl3/binutils/dist/binutils/doc/readelf.1 |   8 ++++++
 external/gpl3/binutils/dist/binutils/readelf.c     |  28 ++++++++++++++++++---
 external/gpl3/binutils/dist/include/elf/common.h   |   9 +++++++
 3 files changed, 41 insertions(+), 4 deletions(-)

diffs (137 lines):

diff -r 5b5cd4d01909 -r a89f048e0dd1 external/gpl3/binutils/dist/binutils/doc/readelf.1
--- a/external/gpl3/binutils/dist/binutils/doc/readelf.1        Sat Dec 13 17:18:55 2014 +0000
+++ b/external/gpl3/binutils/dist/binutils/doc/readelf.1        Sat Dec 13 18:32:59 2014 +0000
@@ -146,6 +146,7 @@
         [\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 @@
 .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
diff -r 5b5cd4d01909 -r a89f048e0dd1 external/gpl3/binutils/dist/binutils/readelf.c
--- a/external/gpl3/binutils/dist/binutils/readelf.c    Sat Dec 13 17:18:55 2014 +0000
+++ b/external/gpl3/binutils/dist/binutils/readelf.c    Sat Dec 13 18:32:59 2014 +0000
@@ -185,6 +185,7 @@
 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 @@
   {"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 @@
   -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 @@
     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 @@
        case 'u':
          do_unwind++;
          break;
+       case 'f':
+         do_special_files++;
+         break;
        case 'h':
          do_header++;
          break;
@@ -12706,14 +12712,24 @@
                (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 @@
     /* 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 @@
       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;
diff -r 5b5cd4d01909 -r a89f048e0dd1 external/gpl3/binutils/dist/include/elf/common.h
--- a/external/gpl3/binutils/dist/include/elf/common.h  Sat Dec 13 17:18:55 2014 +0000
+++ b/external/gpl3/binutils/dist/include/elf/common.h  Sat Dec 13 18:32:59 2014 +0000
@@ -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



Home | Main Index | Thread Index | Old Index