This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit in the dynamic tags
- From: Nick Clifton <nickc at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 11 Aug 2017 15:37:18 -0000
- Subject: [binutils-gdb] Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit in the dynamic tags
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=93ab9c0de7ba4a477720622c7e772d76f646e3f5
commit 93ab9c0de7ba4a477720622c7e772d76f646e3f5
Author: Nick Clifton <nickc@redhat.com>
Date: Fri Aug 11 16:36:28 2017 +0100
Add -z globalaudit linker command line option to set the DF_GLOBALAUDIT flag bit in the dynamic tags.
* 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.
Diff:
---
ld/ChangeLog | 13 +++++++++++++
ld/NEWS | 3 +++
ld/emultempl/elf32.em | 4 ++++
ld/ld.texinfo | 8 ++++++++
ld/lexsup.c | 2 ++
ld/testsuite/ld-elf/audit.exp | 3 +++
ld/testsuite/ld-elf/globalaudit.rd | 3 +++
7 files changed, 36 insertions(+)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 484c36c..fe06729 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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 1393265..bb5a62b 100644
--- 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
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 9ac1840..748f56b 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -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
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index ebe7e7b..bbfa9fd 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -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
diff --git a/ld/lexsup.c b/ld/lexsup.c
index effa277..1adb302 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -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
diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp
index 83ee355..b7af4b7 100644
--- a/ld/testsuite/ld-elf/audit.exp
+++ b/ld/testsuite/ld-elf/audit.exp
@@ -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
index 0000000..fc5de09
--- /dev/null
+++ b/ld/testsuite/ld-elf/globalaudit.rd
@@ -0,0 +1,3 @@
+#...
+.*\(FLAGS_1\).*Flags: GLOBAUDIT
+#pass