Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit...
authorNick Clifton <nickc@redhat.com>
Fri, 11 Aug 2017 15:36:28 +0000 (16:36 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 11 Aug 2017 15:36:28 +0000 (16:36 +0100)
* emultempl/elf32.em (handle_option): Accept the -z globalaudit
command line option.
* lexsup.c (elf_static_list_options): Add -z globalaudit.
* ld.texinfo: Document the support for the new command line
option.
* NEWS: Mention the new feature.
* testsuite/ld-elf/audit.exp: Add a test of the -z globalaudit
command line option.
* testsuite/ld-elf/globalaudit.rd: New file: Expected output from
readelf.

ld/ChangeLog
ld/NEWS
ld/emultempl/elf32.em
ld/ld.texinfo
ld/lexsup.c
ld/testsuite/ld-elf/audit.exp
ld/testsuite/ld-elf/globalaudit.rd [new file with mode: 0644]

index 484c36cb0416e84177edac37f6c33b79b234a30a..fe06729df06e598db2a21901564801d9a6d2e11c 100644 (file)
@@ -1,3 +1,16 @@
+2017-08-11  Nick Clifton  <nickc@redhat.com>
+
+       * emultempl/elf32.em (handle_option): Accept the -z globalaudit
+       command line option.
+       * lexsup.c (elf_static_list_options): Add -z globalaudit.
+       * ld.texinfo: Document the support for the new command line
+       option.
+       * NEWS: Mention the new feature.
+       * testsuite/ld-elf/audit.exp: Add a test of the -z globalaudit
+       command line option.
+       * testsuite/ld-elf/globalaudit.rd: New file: Expected output from
+       readelf.
+
 2017-08-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/21884
diff --git a/ld/NEWS b/ld/NEWS
index 13932657dc64477d23993c11aded89f4d84d33a7..bb5a62bd930cb3bbd6fabfbf8cfa8718ccd0b9d1 100644 (file)
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,4 +1,7 @@
 -*- text -*-
+* Add -z globalaudit command line option to force audit libraries to be run
+  for every dynamic object loaded by an executable - provided that the loader
+  supports this functionality. 
 
 * Tighten linker script grammar around file name specifiers to prevent the use
   of SORT_BY_ALIGNMENT and SORT_BY_INIT_PRIORITY on filenames.  These would
index 9ac184031698d76372b6c662f3f24d4bdad37989..748f56b844f24199581c4cc6cb2377619b22c0fd 100644 (file)
@@ -2676,6 +2676,10 @@ fragment <<EOF
          link_info.noexecstack = TRUE;
          link_info.execstack = FALSE;
        }
+      else if (strcmp (optarg, "globalaudit") == 0)
+       {
+         link_info.flags_1 |= DF_1_GLOBAUDIT;
+       }
 EOF
 
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
index ebe7e7b7bdf250b4c4d1c4f5778f03986dcdc89e..bbfa9fd4f4bc41b0053a7e532cb1ffc994ab0919 100644 (file)
@@ -1136,6 +1136,14 @@ This option is only meaningful when building a shared object.  It makes
 the symbols defined by this shared object available for symbol resolution
 of subsequently loaded libraries.
 
+@item globalaudit
+This option is only meaningful when building a dynamic executable.
+This option marks the executable as requiring global auditing by
+setting the @code{DF_1_GLOBAUDIT} bit in the @code{DT_FLAGS_1} dynamic
+tag.  Global auditing requires that any auditing library defined via
+the @option{--depaudit} or @option{-P} command line options be run for
+all dynamic objects loaded by the application. 
+
 @item initfirst
 This option is only meaningful when building a shared object.
 It marks the object so that its runtime initialization will occur
index effa277b16d1a29fa027e9fa675e800b0fcb70f6..1adb302a14ee6eaa43216eb8c8e45824e9f97f88 100644 (file)
@@ -1828,6 +1828,8 @@ elf_static_list_options (FILE *file)
   -z execstack                Mark executable as requiring executable stack\n"));
   fprintf (file, _("\
   -z noexecstack              Mark executable as not requiring executable stack\n"));
+  fprintf (file, _("\
+  -z globalaudit              Mark executable requiring global auditing\n"));
 }
 
 static void
index 83ee35582e64b9048c073af38162ba4306a54e5a..b7af4b72cf5901783ec89bb4da2f2782c09e0074 100644 (file)
@@ -60,6 +60,9 @@ set build_tests {
   {"Run with -lusesaudit -lusesaudit2"
      "-Ltmpdir/ -lusesaudit -lusesaudit2" ""
      {main.c} {{"readelf" {-d} "depaudit2.rd"}} "useslibusesaudit2.out"}
+  {"Link with -z globalaudit"
+     "-Wl,-Paudit.so -Wl,-z,globalaudit" ""
+     {main.c} {{"readelf" {-d} "globalaudit.rd"}} "globalaudit.out"}   
 }
 
 run_cc_link_tests $build_tests
diff --git a/ld/testsuite/ld-elf/globalaudit.rd b/ld/testsuite/ld-elf/globalaudit.rd
new file mode 100644 (file)
index 0000000..fc5de09
--- /dev/null
@@ -0,0 +1,3 @@
+#...
+.*\(FLAGS_1\).*Flags: GLOBAUDIT
+#pass
This page took 0.034072 seconds and 4 git commands to generate.