• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修訂97a232d7335f3bd0231fd9cd39455bde1d563922 (tree)
時間2018-01-12 17:15:55
作者Nick Clifton <nickc@redh...>
CommiterNick Clifton

Log Message

Add -z undefs option to the ELF linker.

Currently we have no obvious way to revert the action of the "-z defs"
command line option. The "--unresolved-symbols=ignore-in-object-files"
does pretty much what is needed, but it is non-obvious and it also
touches the setting for reporting unresolved symbol references from
shared libraries. So I am proposing adding a "-z undefs" option to be
the inverse of "-z defs". (I thought that "-z nodefs" might be
confusing since it implies banning all definitions, rather than
allowing them).
In addition the description of the "-z defs" option in the linker
documentation is misleading in one place, where it says:
'defs'
Disallows undefined symbols in object files. Undefined
symbols in shared libraries are still allowed.
whereas later on it gets it right:
'-z defs'
Report unresolved symbol references from regular object files.
This is done even if the linker is creating a non-symbolic shared
        1. The switch '--[no-]allow-shlib-undefined' controls the
          behaviour for reporting unresolved references found in shared
          libraries being linked in.

* emultempl/elf32.em (_handle_option): Add support for "-z undefs"
as the opposite of "-z defs".
* ld.texinfo: Document the new option. Update the description of
the -z defs option to make it clear that it does generate an error
if an undefined symbol reference is found in an object file whilst
creating a shared library.
* NEWS: Document this new feature.

Change Summary

差異

--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
1+2018-01-12 Nick Clifton <nickc@redhat.com>
2+
3+ * emultempl/elf32.em (_handle_option): Add support for "-z undefs"
4+ as the opposite of "-z defs".
5+ * ld.texinfo: Document the new option. Update the description of
6+ the -z defs option to make it clear that it does generate an error
7+ if an undefined symbol reference is found in an object file whilst
8+ creating a shared library.
9+ * NEWS: Document this new feature.
10+
111 2018-01-11 H.J. Lu <hongjiu.lu@intel.com>
212
313 * testsuite/ld-elf/pr22393-2a.rd: Replace "-z textonly" with
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,6 +1,9 @@
11 -*- text -*-
2+
23 * Add -z separate-code to generate separate code PT_LOAD segment.
34
5+* Add "-z undefs" command line option as the inverse of the "-z defs" option.
6+
47 * Add -z globalaudit command line option to force audit libraries to be run
58 for every dynamic object loaded by an executable - provided that the loader
69 supports this functionality.
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -2726,6 +2726,8 @@ fragment <<EOF
27262726 case 'z':
27272727 if (strcmp (optarg, "defs") == 0)
27282728 link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR;
2729+ else if (strcmp (optarg, "undefs") == 0)
2730+ link_info.unresolved_syms_in_objects = RM_IGNORE;
27292731 else if (strcmp (optarg, "muldefs") == 0)
27302732 link_info.allow_multiple_definition = TRUE;
27312733 else if (CONST_STRNEQ (optarg, "max-page-size="))
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1147,8 +1147,9 @@ layout will be optimized to minimize memory pages if the system is
11471147 using pages of this size.
11481148
11491149 @item defs
1150-Disallows undefined symbols in object files. Undefined symbols in
1151-shared libraries are still allowed.
1150+Report unresolved symbol references from regular object files. This
1151+is done even if the linker is creating a non-symbolic shared library.
1152+This option is the inverse of @samp{-z undefs}.
11521153
11531154 @item dynamic-undefined-weak
11541155 @itemx nodynamic-undefined-weak
@@ -1288,6 +1289,11 @@ Report an error if DT_TEXTREL is set, i.e., if the binary has dynamic
12881289 relocations in read-only sections. Don't report an error if
12891290 @samp{notext} or @samp{textoff}.
12901291
1292+@item undefs
1293+Do not report unresolved symbol references from regular object files,
1294+either when creating an executable, or when creating a shared library.
1295+This option is the inverse of @samp{-z defs}.
1296+
12911297 @end table
12921298
12931299 Other keywords are ignored for Solaris compatibility.
@@ -1693,6 +1699,7 @@ while linking a large executable.
16931699
16941700 @kindex --no-undefined
16951701 @kindex -z defs
1702+@kindex -z undefs
16961703 @item --no-undefined
16971704 @itemx -z defs
16981705 Report unresolved symbol references from regular object files. This
@@ -1701,6 +1708,8 @@ The switch @option{--[no-]allow-shlib-undefined} controls the
17011708 behaviour for reporting unresolved references found in shared
17021709 libraries being linked in.
17031710
1711+The effects of this option can be reverted by using @code{-z undefs}.
1712+
17041713 @kindex --allow-multiple-definition
17051714 @kindex -z muldefs
17061715 @item --allow-multiple-definition