* emultempl/elf32.em (OPTION_GROUP): New macro.

Add new option Bgroup to longopts.
	(gld*_parse_args): Handle GROUP_OPTION and recognize -z defs.
	(gld*_list_options): Add -Bgroup and -z defs.
	* ld.1: Document -Bgroup and -z defs.
	* ld.texinfo: Likewise.
This commit is contained in:
Ulrich Drepper
2001-03-17 21:24:26 +00:00
parent 249e3833ac
commit a1ab1d2aa3
4 changed files with 90 additions and 45 deletions

View File

@ -1,3 +1,12 @@
2001-03-17 Ulrich Drepper <drepper@redhat.com>
* emultempl/elf32.em (OPTION_GROUP): New macro.
Add new option Bgroup to longopts.
(gld*_parse_args): Handle GROUP_OPTION and recognize -z defs.
(gld*_list_options): Add -Bgroup and -z defs.
* ld.1: Document -Bgroup and -z defs.
* ld.texinfo: Likewise.
2001-03-07 Michael Meissner <meissner@redhat.com> 2001-03-07 Michael Meissner <meissner@redhat.com>
* scripttempl/elfd10v.sc (.rodata,.rodata1,.data1,.sdata): Deal * scripttempl/elfd10v.sc (.rodata,.rodata1,.data1,.sdata): Deal

View File

@ -1334,6 +1334,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
#define OPTION_DISABLE_NEW_DTAGS (400) #define OPTION_DISABLE_NEW_DTAGS (400)
#define OPTION_ENABLE_NEW_DTAGS (OPTION_DISABLE_NEW_DTAGS + 1) #define OPTION_ENABLE_NEW_DTAGS (OPTION_DISABLE_NEW_DTAGS + 1)
#define OPTION_GROUP (OPTION_ENABLE_NEW_DTAGS + 1)
static struct option longopts[] = static struct option longopts[] =
{ {
@ -1347,6 +1348,8 @@ cat >>e${EMULATION_NAME}.c <<EOF
{"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS}, {"disable-new-dtags", no_argument, NULL, OPTION_DISABLE_NEW_DTAGS},
{"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS}, {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
{"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS}, {"enable-new-dtags", no_argument, NULL, OPTION_ENABLE_NEW_DTAGS},
{"Bgroup", no_argument, NULL, OPTION_GROUP},
{"Bgroup", no_argument, NULL, OPTION_GROUP},
EOF EOF
fi fi
@ -1405,6 +1408,12 @@ cat >>e${EMULATION_NAME}.c <<EOF
link_info.new_dtags = true; link_info.new_dtags = true;
break; break;
case OPTION_GROUP:
link_info.flags_1 |= (bfd_vma) DF_1_GROUP;
/* Groups must be self-contained. */
link_info.no_undefined = true;
break;
case 'z': case 'z':
if (strcmp (optarg, "initfirst") == 0) if (strcmp (optarg, "initfirst") == 0)
link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST; link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST;
@ -1430,6 +1439,8 @@ cat >>e${EMULATION_NAME}.c <<EOF
link_info.flags |= (bfd_vma) DF_ORIGIN; link_info.flags |= (bfd_vma) DF_ORIGIN;
link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN; link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN;
} }
else if (strcmp (optarg, "defs") == 0)
link_info.no_undefined = true;
/* What about the other Solaris -z options? FIXME. */ /* What about the other Solaris -z options? FIXME. */
break; break;
EOF EOF
@ -1463,8 +1474,10 @@ EOF
if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then
cat >>e${EMULATION_NAME}.c <<EOF cat >>e${EMULATION_NAME}.c <<EOF
fprintf (file, _(" -Bgroup\t\tSelects group name lookup rules for DSO\n"));
fprintf (file, _(" --disable-new-dtags\tDisable new dynamic tags\n")); fprintf (file, _(" --disable-new-dtags\tDisable new dynamic tags\n"));
fprintf (file, _(" --enable-new-dtags\tEnable new dynamic tags\n")); fprintf (file, _(" --enable-new-dtags\tEnable new dynamic tags\n"));
fprintf (file, _(" -z defs\t\tDisallows undefined symbols\n"));
fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n")); fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n"));
fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n")); fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n"));
fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n")); fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n"));

14
ld/ld.1
View File

@ -29,6 +29,7 @@ ld \- the GNU linker
.I input-format\c .I input-format\c
\&\|] \&\|]
.RB "[\|" \-Bstatic "\|]" .RB "[\|" \-Bstatic "\|]"
.RB "[\|" \-Bgroup "\|]"
.RB "[\|" \-Bdynamic "\|]" .RB "[\|" \-Bdynamic "\|]"
.RB "[\|" \-Bsymbolic "\|]" .RB "[\|" \-Bsymbolic "\|]"
.RB "[\|" "\-c\ "\c .RB "[\|" "\-c\ "\c
@ -406,6 +407,19 @@ Link against dynamic libraries. This is only meaningful on platforms
for which shared libraries are supported. This option is normally the for which shared libraries are supported. This option is normally the
default on such platforms. default on such platforms.
.TP
.B \-Bgroup
Set the \c
.B DF_1_GROUP
\c
flag in the \c
.B DT_FLAGS_1
\c
entry in the dynamic section. This causes the runtime linker to handle
lookups in this object and its dependencies to be performed only inside
the group. No undefined symbols are allowed. This option is only
meaningful on ELF platforms which support shared libraries.
.TP .TP
.B \-Bsymbolic .B \-Bsymbolic
When creating a shared library, bind references to global symbols to When creating a shared library, bind references to global symbols to

View File

@ -301,7 +301,7 @@ You may want to use this option if you are linking files with an unusual
binary format. You can also use @samp{-b} to switch formats explicitly (when binary format. You can also use @samp{-b} to switch formats explicitly (when
linking object files of different formats), by including linking object files of different formats), by including
@samp{-b @var{input-format}} before each group of object files in a @samp{-b @var{input-format}} before each group of object files in a
particular format. particular format.
The default format is taken from the environment variable The default format is taken from the environment variable
@code{GNUTARGET}. @code{GNUTARGET}.
@ -329,7 +329,7 @@ specified by any @samp{-L} options.
@kindex -d @kindex -d
@kindex -dc @kindex -dc
@kindex -dp @kindex -dp
@item -d @item -d
@itemx -dc @itemx -dc
@itemx -dp @itemx -dp
These three options are equivalent; multiple forms are supported for These three options are equivalent; multiple forms are supported for
@ -341,7 +341,7 @@ script command @code{FORCE_COMMON_ALLOCATION} has the same effect.
@cindex entry point, from command line @cindex entry point, from command line
@kindex -e @var{entry} @kindex -e @var{entry}
@kindex --entry=@var{entry} @kindex --entry=@var{entry}
@item -e @var{entry} @item -e @var{entry}
@itemx --entry=@var{entry} @itemx --entry=@var{entry}
Use @var{entry} as the explicit symbol for beginning execution of your Use @var{entry} as the explicit symbol for beginning execution of your
program, rather than the default entry point. If there is no symbol program, rather than the default entry point. If there is no symbol
@ -511,7 +511,7 @@ behaviour of the AIX linker.
@cindex search directory, from cmd line @cindex search directory, from cmd line
@kindex -L@var{dir} @kindex -L@var{dir}
@kindex --library-path=@var{dir} @kindex --library-path=@var{dir}
@item -L@var{searchdir} @item -L@var{searchdir}
@itemx --library-path=@var{searchdir} @itemx --library-path=@var{searchdir}
Add path @var{searchdir} to the list of paths that @code{ld} will search Add path @var{searchdir} to the list of paths that @code{ld} will search
for archive libraries and @code{ld} control scripts. You may use this for archive libraries and @code{ld} control scripts. You may use this
@ -568,13 +568,13 @@ which caused the archive member to be brought in.
@item -n @item -n
@itemx --nmagic @itemx --nmagic
Turn off page alignment of sections, and mark the output as Turn off page alignment of sections, and mark the output as
@code{NMAGIC} if possible. @code{NMAGIC} if possible.
@kindex -N @kindex -N
@kindex --omagic @kindex --omagic
@cindex read/write from cmd line @cindex read/write from cmd line
@cindex OMAGIC @cindex OMAGIC
@item -N @item -N
@itemx --omagic @itemx --omagic
Set the text and data sections to be readable and writable. Also, do Set the text and data sections to be readable and writable. Also, do
not page-align the data segment. If the output format supports Unix not page-align the data segment. If the output format supports Unix
@ -617,7 +617,7 @@ turn serve as input to @code{ld}. This is often called @dfn{partial
linking}. As a side effect, in environments that support standard Unix linking}. As a side effect, in environments that support standard Unix
magic numbers, this option also sets the output file's magic number to magic numbers, this option also sets the output file's magic number to
@code{OMAGIC}. @code{OMAGIC}.
@c ; see @code{-N}. @c ; see @code{-N}.
If this option is not specified, an absolute file is produced. When If this option is not specified, an absolute file is produced. When
linking C++ programs, this option @emph{will not} resolve references to linking C++ programs, this option @emph{will not} resolve references to
constructors; to do that, use @samp{-Ur}. constructors; to do that, use @samp{-Ur}.
@ -641,21 +641,21 @@ the @code{-rpath} option.
@kindex -s @kindex -s
@kindex --strip-all @kindex --strip-all
@cindex strip all symbols @cindex strip all symbols
@item -s @item -s
@itemx --strip-all @itemx --strip-all
Omit all symbol information from the output file. Omit all symbol information from the output file.
@kindex -S @kindex -S
@kindex --strip-debug @kindex --strip-debug
@cindex strip debugger symbols @cindex strip debugger symbols
@item -S @item -S
@itemx --strip-debug @itemx --strip-debug
Omit debugger symbol information (but not all symbols) from the output file. Omit debugger symbol information (but not all symbols) from the output file.
@kindex -t @kindex -t
@kindex --trace @kindex --trace
@cindex input files, displaying @cindex input files, displaying
@item -t @item -t
@itemx --trace @itemx --trace
Print the names of the input files as @code{ld} processes them. Print the names of the input files as @code{ld} processes them.
@ -687,7 +687,7 @@ option is equivalent to the @code{EXTERN} linker script command.
@kindex -Ur @kindex -Ur
@cindex constructors @cindex constructors
@item -Ur @item -Ur
For anything other than C++ programs, this option is equivalent to For anything other than C++ programs, this option is equivalent to
@samp{-r}: it generates relocatable output---i.e., an output file that can in @samp{-r}: it generates relocatable output---i.e., an output file that can in
turn serve as input to @code{ld}. When linking C++ programs, @samp{-Ur} turn serve as input to @code{ld}. When linking C++ programs, @samp{-Ur}
@ -728,7 +728,7 @@ Delete all local symbols.
@kindex --discard-locals @kindex --discard-locals
@cindex local symbols, deleting @cindex local symbols, deleting
@cindex L, deleting symbols beginning @cindex L, deleting symbols beginning
@item -X @item -X
@itemx --discard-locals @itemx --discard-locals
Delete all temporary local symbols. For most targets, this is all local Delete all temporary local symbols. For most targets, this is all local
symbols whose names begin with @samp{L}. symbols whose names begin with @samp{L}.
@ -767,6 +767,7 @@ of this object will ignore any default library search paths.
@code{nodump} marks the object can not be dumped by @code{dldump}. @code{nodump} marks the object can not be dumped by @code{dldump}.
@code{now} marks the object with the non-lazy runtime binding. @code{now} marks the object with the non-lazy runtime binding.
@code{origin} marks the object may contain $ORIGIN. @code{origin} marks the object may contain $ORIGIN.
@code{defs} disallows undefined symbols.
@kindex -( @kindex -(
@cindex groups of archives @cindex groups of archives
@ -805,11 +806,19 @@ for compatibility with various systems. You may use this option
multiple times on the command line: it affects library searching for multiple times on the command line: it affects library searching for
@code{-l} options which follow it. @code{-l} options which follow it.
@kindex -Bgroup
@item -Bgroup
Set the @code{DF_1_GROUP} flag in the @code{DT_FLAGS_1} entry in the dynamic
section. This causes the runtime linker to handle lookups in this
object and its dependencies to be performed only inside the group.
@code{--no-undefined} is implied. This option is only meaningful on ELF
platforms which support shared libraries.
@kindex -Bstatic @kindex -Bstatic
@kindex -dn @kindex -dn
@kindex -non_shared @kindex -non_shared
@kindex -static @kindex -static
@item -Bstatic @item -Bstatic
@itemx -dn @itemx -dn
@itemx -non_shared @itemx -non_shared
@itemx -static @itemx -static
@ -875,9 +884,9 @@ These options control whether to demangle symbol names in error messages
and other output. When the linker is told to demangle, it tries to and other output. When the linker is told to demangle, it tries to
present symbol names in a readable fashion: it strips leading present symbol names in a readable fashion: it strips leading
underscores if they are used by the object file format, and converts C++ underscores if they are used by the object file format, and converts C++
mangled symbol names into user readable names. Different compilers have mangled symbol names into user readable names. Different compilers have
different mangling styles. The optional demangling style argument can be used different mangling styles. The optional demangling style argument can be used
to choose an appropriate demangling style for your compiler. The linker will to choose an appropriate demangling style for your compiler. The linker will
demangle by default unless the environment variable @samp{COLLECT_NO_DEMANGLE} demangle by default unless the environment variable @samp{COLLECT_NO_DEMANGLE}
is set. These options may be used to override the default. is set. These options may be used to override the default.
@ -945,9 +954,11 @@ necessary. This may be required if @code{ld} runs out of memory space
while linking a large executable. while linking a large executable.
@kindex --no-undefined @kindex --no-undefined
@kindex -z defs
@item --no-undefined @item --no-undefined
@itemx -z defs
Normally when creating a non-symbolic shared library, undefined symbols Normally when creating a non-symbolic shared library, undefined symbols
are allowed and left to be resolved by the runtime loader. This option are allowed and left to be resolved by the runtime loader. These options
disallows such undefined symbols. disallows such undefined symbols.
@kindex --allow-shlib-undefined @kindex --allow-shlib-undefined
@ -1014,7 +1025,7 @@ This option is ignored for SVR4 compatibility.
@cindex synthesizing linker @cindex synthesizing linker
@cindex relaxing addressing modes @cindex relaxing addressing modes
@item --relax @item --relax
An option with machine dependent effects. An option with machine dependent effects.
@ifset GENERIC @ifset GENERIC
This option is only supported on a few targets. This option is only supported on a few targets.
@end ifset @end ifset
@ -1849,15 +1860,15 @@ There are several ways to set the entry point. The linker will set the
entry point by trying each of the following methods in order, and entry point by trying each of the following methods in order, and
stopping when one of them succeeds: stopping when one of them succeeds:
@itemize @bullet @itemize @bullet
@item @item
the @samp{-e} @var{entry} command-line option; the @samp{-e} @var{entry} command-line option;
@item @item
the @code{ENTRY(@var{symbol})} command in a linker script; the @code{ENTRY(@var{symbol})} command in a linker script;
@item @item
the value of the symbol @code{start}, if defined; the value of the symbol @code{start}, if defined;
@item @item
the address of the first byte of the @samp{.text} section, if present; the address of the first byte of the @samp{.text} section, if present;
@item @item
The address @code{0}. The address @code{0}.
@end itemize @end itemize
@ -2216,7 +2227,7 @@ in the first input file. The first section will be at address zero.
@subsection Output section description @subsection Output section description
The full description of an output section looks like this: The full description of an output section looks like this:
@smallexample @smallexample
@group @group
@var{section} [@var{address}] [(@var{type})] : [AT(@var{lma})] @var{section} [@var{address}] [(@var{type})] : [AT(@var{lma})]
@{ @{
@var{output-section-command} @var{output-section-command}
@ -2507,7 +2518,7 @@ notation is now considered obsolete. It is equivalent to
@cindex KEEP @cindex KEEP
@cindex garbage collection @cindex garbage collection
When link-time garbage collection is in use (@samp{--gc-sections}), When link-time garbage collection is in use (@samp{--gc-sections}),
it is often useful to mark sections that should not be eliminated. it is often useful to mark sections that should not be eliminated.
This is accomplished by surrounding an input section's wildcard entry This is accomplished by surrounding an input section's wildcard entry
with @code{KEEP()}, as in @code{KEEP(*(.init))} or with @code{KEEP()}, as in @code{KEEP(*(.init))} or
@code{KEEP(SORT(*)(.ctors))}. @code{KEEP(SORT(*)(.ctors))}.
@ -2544,7 +2555,7 @@ SECTIONS @{
@} @}
@} @}
@end group @end group
@end smallexample @end smallexample
@node Output Section Data @node Output Section Data
@subsection Output section data @subsection Output section data
@ -2731,7 +2742,7 @@ section named @samp{/DISCARD/} are not included in the output file.
We showed above that the full description of an output section looked We showed above that the full description of an output section looked
like this: like this:
@smallexample @smallexample
@group @group
@var{section} [@var{address}] [(@var{type})] : [AT(@var{lma})] @var{section} [@var{address}] [(@var{type})] : [AT(@var{lma})]
@{ @{
@var{output-section-command} @var{output-section-command}
@ -2744,7 +2755,7 @@ We've already described @var{section}, @var{address}, and
@var{output-section-command}. In this section we will describe the @var{output-section-command}. In this section we will describe the
remaining section attributes. remaining section attributes.
@menu @menu
* Output Section Type:: Output section type * Output Section Type:: Output section type
* Output Section LMA:: Output section LMA * Output Section LMA:: Output section LMA
* Output Section Region:: Output section region * Output Section Region:: Output section region
@ -2822,7 +2833,7 @@ counter holds the VMA value, not the LMA value.
SECTIONS SECTIONS
@{ @{
.text 0x1000 : @{ *(.text) _etext = . ; @} .text 0x1000 : @{ *(.text) _etext = . ; @}
.mdata 0x2000 : .mdata 0x2000 :
AT ( ADDR (.text) + SIZEOF (.text) ) AT ( ADDR (.text) + SIZEOF (.text) )
@{ _data = . ; *(.data); _edata = . ; @} @{ _data = . ; *(.data); _edata = . ; @}
.bss 0x3000 : .bss 0x3000 :
@ -3049,7 +3060,7 @@ command. However, you can define as many blocks of memory within it as
you wish. The syntax is: you wish. The syntax is:
@smallexample @smallexample
@group @group
MEMORY MEMORY
@{ @{
@var{name} [(@var{attr})] : ORIGIN = @var{origin}, LENGTH = @var{len} @var{name} [(@var{attr})] : ORIGIN = @var{origin}, LENGTH = @var{len}
@dots{} @dots{}
@ -3124,7 +3135,7 @@ region.
@smallexample @smallexample
@group @group
MEMORY MEMORY
@{ @{
rom (rx) : ORIGIN = 0, LENGTH = 256K rom (rx) : ORIGIN = 0, LENGTH = 256K
ram (!rx) : org = 0x40000000, l = 4M ram (!rx) : org = 0x40000000, l = 4M
@ -3328,9 +3339,9 @@ VERS_1.1 @{
global: global:
foo1; foo1;
local: local:
old*; old*;
original*; original*;
new*; new*;
@}; @};
VERS_1.2 @{ VERS_1.2 @{
@ -3612,7 +3623,7 @@ precedence associativity Operators Notes
(lowest) (lowest)
@end smallexample @end smallexample
Notes: Notes:
(1) Prefix operators (1) Prefix operators
(2) @xref{Assignments}. (2) @xref{Assignments}.
@c TEXI2ROFF-KILL @c TEXI2ROFF-KILL
@end ifinfo @end ifinfo
@ -3630,7 +3641,7 @@ height2pt&\omit&&\omit&&\omit&\cr
height2pt&\omit&&\omit&&\omit&\cr height2pt&\omit&&\omit&&\omit&\cr
&highest&&&&&\cr &highest&&&&&\cr
% '176 is tilde, '~' in tt font % '176 is tilde, '~' in tt font
&1&&left&&\qquad- \char'176\ !\qquad\dag&\cr &1&&left&&\qquad- \char'176\ !\qquad\dag&\cr
&2&&left&&* / \%&\cr &2&&left&&* / \%&\cr
&3&&left&&+ -&\cr &3&&left&&+ -&\cr
&4&&left&&>> <<&\cr &4&&left&&>> <<&\cr
@ -3685,7 +3696,7 @@ following
@group @group
SECTIONS SECTIONS
@{ @{
.text 9+this_isnt_constant : .text 9+this_isnt_constant :
@{ *(.text) @} @{ *(.text) @}
@} @}
@end group @end group
@ -3760,7 +3771,7 @@ identical values:
@group @group
SECTIONS @{ @dots{} SECTIONS @{ @dots{}
.output1 : .output1 :
@{ @{
start_of_output_1 = ABSOLUTE(.); start_of_output_1 = ABSOLUTE(.);
@dots{} @dots{}
@} @}
@ -4073,7 +4084,7 @@ non-interworking aware Thumb code.
@cindex entry point, thumb @cindex entry point, thumb
@kindex --thumb-entry=@var{entry} @kindex --thumb-entry=@var{entry}
The @samp{--thumb-entry} switch is a duplicate of the generic The @samp{--thumb-entry} switch is a duplicate of the generic
@samp{--entry} switch, in that it sets the program's starting address. @samp{--entry} switch, in that it sets the program's starting address.
But it also sets the bottom bit of the address, so that it can be But it also sets the bottom bit of the address, so that it can be
branched to using a BX instruction, and the program will start branched to using a BX instruction, and the program will start
executing in Thumb mode straight away. executing in Thumb mode straight away.
@ -4451,10 +4462,10 @@ This command does nothing whatever; it's only accepted for compatibility.
@cindex @code{FORMAT} (MRI) @cindex @code{FORMAT} (MRI)
@item FORMAT @var{output-format} @item FORMAT @var{output-format}
Similar to the @code{OUTPUT_FORMAT} command in the more general linker Similar to the @code{OUTPUT_FORMAT} command in the more general linker
language, but restricted to one of these output formats: language, but restricted to one of these output formats:
@enumerate @enumerate
@item @item
S-records, if @var{output-format} is @samp{S} S-records, if @var{output-format} is @samp{S}
@item @item
@ -4517,12 +4528,12 @@ If you have more than one @code{SECT} statement for the same
@cindex GNU Free Documentation License @cindex GNU Free Documentation License
GNU Free Documentation License GNU Free Documentation License
Version 1.1, March 2000 Version 1.1, March 2000
Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
@ -4899,5 +4910,3 @@ to permit their use in free software.
@contents @contents
@bye @bye