binutils-gdb/ld/testsuite/ld-undefined
Andrew Burgess 0a61824343 ld: Add '--require-defined' command line option.
Add a new command line option '--require-defined' to the linker.  This
option operates identically to the '--undefined' option, except that if
the symbol is not defined in the final output file then the linker will
exit with an error.

When making use of --gc-section, or just when trying to pull in parts of
a library, it is not uncommon for a user to use the '--undefined'
command line option to specify a symbol that the user then expects to be
defined by one of the object files supplied to the link.

However, if for any reason the symbol is not satisfied by an object
provided to the link the user will be left with an undefined symbol in
the output file, instead of a defined symbol.

In some cases the above behaviour is what the user wants, in other cases
though we can do better.  The '--require-defined' option tries to fill
this gap.  The symbol passed to the '--require-defined' option is
treated exactly as if the symbol was passed to '--undefined', however,
before the linker exits a check is made that all symbols passed to
'--require-defined' are actually defined, if any are not then the link
will fail with an error.

ld/ChangeLog:

	* ld.texinfo (Options): Document --require-defined option.
	* ldlang.c (struct require_defined_symbol): New structure.
	(require_defined_symbol_list): New variable.
	(ldlang_add_require_defined): New function.
	(ldlang_check_require_defined_symbols): New function.
	(lang_process): Check required symbols are defined.
	* ldlang.h (ldlang_add_require_defined): Declare.
	* ldlex.h (enum option_values): Add OPTION_REQUIRE_DEFINED_SYMBOL.
	* lexsup.c (ld_options): Add '--require-defined' entry.
	(parse_args): Handle '--require-defined' entry.
	* NEWS: Mention new '--require-defined' option.

ld/testsuite/ChangeLog:

	* ld-undefined/require-defined-1.d: New file.
	* ld-undefined/require-defined-2.d: New file.
	* ld-undefined/require-defined-3.d: New file.
	* ld-undefined/require-defined-4.d: New file.
	* ld-undefined/require-defined-5.d: New file.
	* ld-undefined/require-defined.exp: New file.
	* ld-undefined/require-defined.s: New file.
2015-08-04 10:00:05 +01:00
..
dummy.s ld/ 2009-03-18 12:11:38 +00:00
entry-1.d ld/ 2009-03-18 12:11:38 +00:00
entry-2.d ld/ 2009-03-18 12:11:38 +00:00
entry-3.d Improve binutils testsuite coverage for GNU/Hurd. 2010-11-08 06:43:40 +00:00
entry-4.d Improve binutils testsuite coverage for GNU/Hurd. 2010-11-08 06:43:40 +00:00
entry-5.d ld/ 2009-03-18 12:11:38 +00:00
entry-6.d ld/ 2009-03-18 12:11:38 +00:00
entry-7.d 2009-09-14 H.J. Lu <hongjiu.lu@intel.com> 2009-09-14 14:07:26 +00:00
entry.exp ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
entry.s ld/ 2009-03-18 12:11:38 +00:00
require-defined-1.d ld: Add '--require-defined' command line option. 2015-08-04 10:00:05 +01:00
require-defined-2.d ld: Add '--require-defined' command line option. 2015-08-04 10:00:05 +01:00
require-defined-3.d ld: Add '--require-defined' command line option. 2015-08-04 10:00:05 +01:00
require-defined-4.d ld: Add '--require-defined' command line option. 2015-08-04 10:00:05 +01:00
require-defined-5.d ld: Add '--require-defined' command line option. 2015-08-04 10:00:05 +01:00
require-defined.exp ld: Add '--require-defined' command line option. 2015-08-04 10:00:05 +01:00
require-defined.s ld: Add '--require-defined' command line option. 2015-08-04 10:00:05 +01:00
undefined.c 19990502 sourceware import 1999-05-03 07:29:11 +00:00
undefined.exp ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
weak-undef.exp ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
weak-undef.s gas/testsuite/ 2005-03-22 14:20:38 +00:00
weak-undef.t 2001-01-01 Philip Blundell <philb@gnu.org> 2001-01-01 14:54:03 +00:00