Add "-z undefs" option to the linker.

This commit is contained in:
Nick Clifton 2018-01-16 11:59:58 +00:00
parent 635411c923
commit a62fb5b34e
2 changed files with 81 additions and 1 deletions

71
binutils-z-undefs.patch Normal file
View File

@ -0,0 +1,71 @@
diff -rup binutils.orig/ld/emultempl/elf32.em binutils-2.29.1/ld/emultempl/elf32.em
--- binutils.orig/ld/emultempl/elf32.em 2018-01-16 11:34:58.040749108 +0000
+++ binutils-2.29.1/ld/emultempl/elf32.em 2018-01-16 11:35:35.697303875 +0000
@@ -2666,6 +2666,8 @@ fragment <<EOF
case 'z':
if (strcmp (optarg, "defs") == 0)
link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
+ else if (strcmp (optarg, "undefs") == 0)
+ link_info.unresolved_syms_in_objects = RM_IGNORE;
else if (strcmp (optarg, "muldefs") == 0)
link_info.allow_multiple_definition = TRUE;
else if (CONST_STRNEQ (optarg, "max-page-size="))
Only in binutils-2.29.1/ld/emultempl: elf32.em.orig
diff -rup binutils.orig/ld/ld.texinfo binutils-2.29.1/ld/ld.texinfo
--- binutils.orig/ld/ld.texinfo 2018-01-16 11:34:58.208747127 +0000
+++ binutils-2.29.1/ld/ld.texinfo 2018-01-16 11:35:35.699303851 +0000
@@ -1125,8 +1125,9 @@ Generate common symbols with the STT_COM
link.
@item defs
-Disallows undefined symbols in object files. Undefined symbols in
-shared libraries are still allowed.
+Report unresolved symbol references from regular object files. This
+is done even if the linker is creating a non-symbolic shared library.
+This option is the inverse of @samp{-z undefs}.
@item execstack
Marks the object as requiring executable stack.
@@ -1279,6 +1280,11 @@ Generate GNU_PROPERTY_X86_FEATURE_1_SHST
to indicate compatibility with Intel Shadow Stack. Supported for
Linux/i386 and Linux/x86_64.
+@item undefs
+Do not report unresolved symbol references from regular object files,
+either when creating an executable, or when creating a shared library.
+This option is the inverse of @samp{-z defs}.
+
@end table
Other keywords are ignored for Solaris compatibility.
@@ -1684,6 +1690,7 @@ while linking a large executable.
@kindex --no-undefined
@kindex -z defs
+@kindex -z undefs
@item --no-undefined
@itemx -z defs
Report unresolved symbol references from regular object files. This
@@ -1692,6 +1699,8 @@ The switch @option{--[no-]allow-shlib-un
behaviour for reporting unresolved references found in shared
libraries being linked in.
+The effects of this option can be reverted by using @code{-z undefs}.
+
@kindex --allow-multiple-definition
@kindex -z muldefs
@item --allow-multiple-definition
Only in binutils-2.29.1/ld: ld.texinfo.orig
diff -rup binutils.orig/ld/NEWS binutils-2.29.1/ld/NEWS
--- binutils.orig/ld/NEWS 2018-01-16 11:34:58.209747115 +0000
+++ binutils-2.29.1/ld/NEWS 2018-01-16 11:35:57.855041557 +0000
@@ -1,5 +1,7 @@
-*- text -*-
+* Add "-z undefs" command line option as the inverse of the "-z defs" option.
+
Changes in 2.29:
* Support for -z shstk in the x86 ELF linker to generate
Only in binutils-2.29.1/ld: NEWS.orig
Only in binutils-2.29.1/ld: NEWS.rej

View File

@ -54,7 +54,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.29.1
Release: 11%{?dist}
Release: 12%{?dist}
License: GPLv3+
Group: Development/Tools
URL: https://sourceware.org/binutils
@ -154,6 +154,11 @@ Patch12: binutils-readelf-other-sym-info.patch
# Lifetime: Fixed in 2.30.
Patch13: binutils-support-v3-build-notes.patch
# Purpose: Adds a "-z undefs" option to the linker to compliment the already
# present "-z defs" option.
# Lifetime: Fixed in 2.30.
Patch14: binutils-z-undefs.patch
#----------------------------------------------------------------------------
Provides: bundled(libiberty)
@ -289,6 +294,7 @@ using libelf instead of BFD.
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -693,6 +699,9 @@ exit 0
#----------------------------------------------------------------------------
%changelog
* Tue Jan 16 2018 Nick Clifton <nickc@redhat.com> 2.29.1-12
- Add "-z undefs" option to the linker.
* Thu Jan 11 2018 Nick Clifton <nickc@redhat.com> 2.29.1-11
- *Do* enable relro by default for the PowerPC64 architecture. (#1523946)