Blame SOURCES/binutils-2.27-add-globalaudit-support.patch

6cffa7
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
6cffa7
index 9ac1840316..748f56b844 100644
6cffa7
--- a/ld/emultempl/elf32.em
6cffa7
+++ b/ld/emultempl/elf32.em
6cffa7
@@ -2676,6 +2676,10 @@ fragment <
6cffa7
 	  link_info.noexecstack = TRUE;
6cffa7
 	  link_info.execstack = FALSE;
6cffa7
 	}
6cffa7
+      else if (strcmp (optarg, "globalaudit") == 0)
6cffa7
+	{
6cffa7
+	  link_info.flags_1 |= DF_1_GLOBAUDIT;
6cffa7
+	}
6cffa7
 EOF
6cffa7
 
6cffa7
 if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
6cffa7
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
6cffa7
index ebe7e7b7bd..bbfa9fd4f4 100644
6cffa7
--- a/ld/ld.texinfo
6cffa7
+++ b/ld/ld.texinfo
6cffa7
@@ -1136,6 +1136,14 @@ This option is only meaningful when building a shared object.  It makes
6cffa7
 the symbols defined by this shared object available for symbol resolution
6cffa7
 of subsequently loaded libraries.
6cffa7
 
6cffa7
+@item globalaudit
6cffa7
+This option is only meaningful when building a dynamic executable.
6cffa7
+This option marks the executable as requiring global auditing by
6cffa7
+setting the @code{DF_1_GLOBAUDIT} bit in the @code{DT_FLAGS_1} dynamic
6cffa7
+tag.  Global auditing requires that any auditing library defined via
6cffa7
+the @option{--depaudit} or @option{-P} command line options be run for
6cffa7
+all dynamic objects loaded by the application. 
6cffa7
+
6cffa7
 @item initfirst
6cffa7
 This option is only meaningful when building a shared object.
6cffa7
 It marks the object so that its runtime initialization will occur
6cffa7
diff --git a/ld/lexsup.c b/ld/lexsup.c
6cffa7
index effa277b16..1adb302a14 100644
6cffa7
--- a/ld/lexsup.c
6cffa7
+++ b/ld/lexsup.c
6cffa7
@@ -1828,6 +1828,8 @@ elf_static_list_options (FILE *file)
6cffa7
   -z execstack                Mark executable as requiring executable stack\n"));
6cffa7
   fprintf (file, _("\
6cffa7
   -z noexecstack              Mark executable as not requiring executable stack\n"));
6cffa7
+  fprintf (file, _("\
6cffa7
+  -z globalaudit              Mark executable requiring global auditing\n"));
6cffa7
 }
6cffa7
 
6cffa7
 static void
6cffa7
diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp
6cffa7
index 83ee35582e..b7af4b72cf 100644
6cffa7
--- a/ld/testsuite/ld-elf/audit.exp
6cffa7
+++ b/ld/testsuite/ld-elf/audit.exp
6cffa7
@@ -60,6 +60,9 @@ set build_tests {
6cffa7
   {"Run with -lusesaudit -lusesaudit2"
6cffa7
      "-Ltmpdir/ -lusesaudit -lusesaudit2" ""
6cffa7
      {main.c} {{"readelf" {-d} "depaudit2.rd"}} "useslibusesaudit2.out"}
6cffa7
+  {"Link with -z globalaudit"
6cffa7
+     "-Wl,-Paudit.so -Wl,-z,globalaudit" ""
6cffa7
+     {main.c} {{"readelf" {-d} "globalaudit.rd"}} "globalaudit.out"}	
6cffa7
 }
6cffa7
 
6cffa7
 run_cc_link_tests $build_tests
6cffa7
--- /dev/null	2017-08-11 08:05:42.291658471 +0100
6cffa7
+++ ld/testsuite/ld-elf/globalaudit.rd	2017-08-11 15:32:41.009073026 +0100
6cffa7
@@ -0,0 +1,3 @@
6cffa7
+#...
6cffa7
+.*\(FLAGS_1\).*Flags: GLOBAUDIT
6cffa7
+#pass