From 97a232d7335f3bd0231fd9cd39455bde1d563922 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Fri, 12 Jan 2018 08:15:55 +0000 Subject: [PATCH] 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 library. 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. --- ld/ChangeLog | 10 ++++++++++ ld/NEWS | 3 +++ ld/emultempl/elf32.em | 2 ++ ld/ld.texinfo | 13 +++++++++++-- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 19e34da..a2c13c8 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2018-01-12 Nick Clifton + + * 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. + 2018-01-11 H.J. Lu * testsuite/ld-elf/pr22393-2a.rd: Replace "-z textonly" with diff --git a/ld/NEWS b/ld/NEWS index 0d40ccd..69c8b1d 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,6 +1,9 @@ -*- text -*- + * Add -z separate-code to generate separate code PT_LOAD segment. +* Add "-z undefs" command line option as the inverse of the "-z defs" option. + * 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. diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 8ff19bf..c0925fc 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -2726,6 +2726,8 @@ fragment <