Update HEAD with the stock files.

This commit is contained in:
David E. O'Brien 2002-12-02 09:39:02 +00:00
parent fc91886f96
commit a46000f2ca
8 changed files with 263 additions and 257 deletions

View File

@ -18,8 +18,6 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* $FreeBSD$ */
#include "bfd.h"
#include "sysdep.h"
#include "bfdlink.h"

View File

@ -19,8 +19,6 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* $FreeBSD$ */
/* We need a published ABI spec for this. Until one comes out, don't
assume this'll remain unchanged forever. */

View File

@ -921,6 +921,7 @@ elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
boolean size_change_ok;
char *shortname;
struct elf_link_hash_entry *hi;
struct bfd_link_hash_entry *bh;
struct elf_backend_data *bed;
boolean collect;
boolean dynamic;
@ -979,11 +980,12 @@ elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
if (! override)
{
bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, shortname, BSF_INDIRECT, bfd_ind_section_ptr,
(bfd_vma) 0, name, false, collect,
(struct bfd_link_hash_entry **) &hi)))
(bfd_vma) 0, name, false, collect, &bh)))
return false;
hi = (struct elf_link_hash_entry *) bh;
}
else
{
@ -1098,11 +1100,12 @@ elf_add_default_symbol (abfd, info, h, name, sym, psec, value,
}
else
{
bh = &hi->root;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, shortname, BSF_INDIRECT,
bfd_ind_section_ptr, (bfd_vma) 0, name, false,
collect, (struct bfd_link_hash_entry **) &hi)))
bfd_ind_section_ptr, (bfd_vma) 0, name, false, collect, &bh)))
return false;
hi = (struct elf_link_hash_entry *) bh;
/* If there is a duplicate definition somewhere, then HI may not
point to an indirect symbol. We will have reported an error
@ -1295,6 +1298,14 @@ elf_link_add_object_symbols (abfd, info)
const char *name;
bfd_size_type oldsize;
bfd_size_type strindex;
struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
/* ld --just-symbols and dynamic objects don't mix very well.
Test for --just-symbols by looking at info set up by
_bfd_elf_link_just_syms. */
if ((s = abfd->sections) != NULL
&& elf_section_data (s)->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
goto error_return;
/* Find the name to use in a DT_NEEDED entry that refers to this
object. If the object has a DT_SONAME entry, we use it.
@ -1324,8 +1335,6 @@ elf_link_add_object_symbols (abfd, info)
Elf_External_Dyn *extdynend;
int elfsec;
unsigned long shlink;
int rpath;
int runpath;
dynbuf = (Elf_External_Dyn *) bfd_malloc (s->_raw_size);
if (dynbuf == NULL)
@ -1342,8 +1351,6 @@ elf_link_add_object_symbols (abfd, info)
extdyn = dynbuf;
extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn);
rpath = 0;
runpath = 0;
for (; extdyn < extdynend; extdyn++)
{
Elf_Internal_Dyn dyn;
@ -1387,13 +1394,6 @@ elf_link_add_object_symbols (abfd, info)
char *fnm, *anm;
unsigned int tagv = dyn.d_un.d_val;
/* When we see DT_RPATH before DT_RUNPATH, we have
to clear runpath. Do _NOT_ bfd_release, as that
frees all more recently bfd_alloc'd blocks as
well. */
if (rpath && hash_table->runpath)
hash_table->runpath = NULL;
amt = sizeof (struct bfd_link_needed_list);
n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
@ -1407,13 +1407,11 @@ elf_link_add_object_symbols (abfd, info)
n->name = anm;
n->by = abfd;
n->next = NULL;
for (pn = & hash_table->runpath;
for (pn = & runpath;
*pn != NULL;
pn = &(*pn)->next)
;
*pn = n;
runpath = 1;
rpath = 0;
}
/* Ignore DT_RPATH if we have seen DT_RUNPATH. */
if (!runpath && dyn.d_tag == DT_RPATH)
@ -1439,18 +1437,32 @@ elf_link_add_object_symbols (abfd, info)
n->name = anm;
n->by = abfd;
n->next = NULL;
for (pn = & hash_table->runpath;
for (pn = & rpath;
*pn != NULL;
pn = &(*pn)->next)
;
*pn = n;
rpath = 1;
}
}
free (dynbuf);
}
/* DT_RUNPATH overrides DT_RPATH. Do _NOT_ bfd_release, as that
frees all more recently bfd_alloc'd blocks as well. */
if (runpath)
rpath = runpath;
if (rpath)
{
struct bfd_link_needed_list **pn;
for (pn = & hash_table->runpath;
*pn != NULL;
pn = &(*pn)->next)
;
*pn = rpath;
}
/* We do not want to include any of the sections in a dynamic
object in the output file. We hack by simply clobbering the
list of sections in the BFD. This could be handled more
@ -1926,19 +1938,17 @@ elf_link_add_object_symbols (abfd, info)
might be needed here. */
if (isym->st_other != 0)
{
unsigned char hvis, symvis, other;
/* Take the balance of OTHER from the definition. */
other = (definition ? isym->st_other : h->other);
other &= ~ ELF_ST_VISIBILITY (-1);
/* Combine visibilities, using the most constraining one. */
unsigned char hvis = ELF_ST_VISIBILITY (h->other);
unsigned char symvis = ELF_ST_VISIBILITY (isym->st_other);
hvis = ELF_ST_VISIBILITY (h->other);
symvis = ELF_ST_VISIBILITY (isym->st_other);
if (symvis && (hvis > symvis || hvis == 0))
h->other = isym->st_other;
/* If neither has visibility, use the st_other of the
definition. This is an arbitrary choice, since the
other bits have no general meaning. */
if (!symvis && !hvis
&& (definition || h->other == 0))
h->other = isym->st_other;
h->other = other | (hvis > symvis ? hvis : symvis);
}
/* Set a flag in the hash table entry indicating the type of
@ -2292,6 +2302,7 @@ elf_link_create_dynamic_sections (abfd, info)
flagword flags;
register asection *s;
struct elf_link_hash_entry *h;
struct bfd_link_hash_entry *bh;
struct elf_backend_data *bed;
if (! is_elf_hash_table (info))
@ -2384,12 +2395,12 @@ elf_link_create_dynamic_sections (abfd, info)
creating a .dynamic section. We don't want to define it if there
is no .dynamic section, since on some ELF platforms the start up
code examines it to decide how to initialize the process. */
h = NULL;
bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, "_DYNAMIC", BSF_GLOBAL, s, (bfd_vma) 0,
(const char *) NULL, false, get_elf_backend_data (abfd)->collect,
(struct bfd_link_hash_entry **) &h)))
(const char *) 0, false, get_elf_backend_data (abfd)->collect, &bh)))
return false;
h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@ -3326,19 +3337,20 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath,
unsigned int cdeps;
struct bfd_elf_version_deps *n;
struct elf_link_hash_entry *h;
struct bfd_link_hash_entry *bh;
cdeps = 0;
for (n = t->deps; n != NULL; n = n->next)
++cdeps;
/* Add a symbol representing this version. */
h = NULL;
bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, dynobj, t->name, BSF_GLOBAL, bfd_abs_section_ptr,
(bfd_vma) 0, (const char *) NULL, false,
get_elf_backend_data (dynobj)->collect,
(struct bfd_link_hash_entry **) &h)))
get_elf_backend_data (dynobj)->collect, &bh)))
return false;
h = (struct elf_link_hash_entry *) bh;
h->elf_link_hash_flags &= ~ ELF_LINK_NON_ELF;
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
@ -3886,9 +3898,12 @@ elf_fix_symbol_flags (h, eif)
{
struct elf_link_hash_entry *weakdef;
weakdef = h->weakdef;
if (h->root.type == bfd_link_hash_indirect)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
BFD_ASSERT (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak);
weakdef = h->weakdef;
BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
|| weakdef->root.type == bfd_link_hash_defweak);
BFD_ASSERT (weakdef->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC);
@ -6335,11 +6350,10 @@ elf_link_output_extsym (h, data)
sym.st_info = ELF_ST_INFO (bindtype, ELF_ST_TYPE (sym.st_info));
}
/* If a symbol is not defined locally, we clear the visibility
field. */
/* If a symbol is not defined locally, we clear the visibility field. */
if (! finfo->info->relocateable
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
sym.st_other ^= ELF_ST_VISIBILITY (sym.st_other);
sym.st_other &= ~ ELF_ST_VISIBILITY (-1);
/* If this symbol should be put in the .dynsym section, then put it
there now. We already know the symbol index. We also fill in

File diff suppressed because it is too large Load Diff

View File

@ -115,14 +115,8 @@ changequote([,])dnl
endian=
case ${cpu} in
alpha*) cpu_type=alpha ;;
armeb) cpu_type=arm endian=big ;;
arm*) cpu_type=arm endian=little ;;
armb*) cpu_type=arm endian=little ;;
armv*l) cpu_type=arm endian=little ;;
armv*b) cpu_type=arm endian=big ;;
xscale*) cpu_type=arm endian=little ;;
strongarm*) cpu_type=arm endian=little ;;
thumb*) cpu_type=arm endian=little ;;
arm*b|xscale*b|strongarm*b) cpu_type=arm endian=big ;;
arm*|xscale*|strongarm*) cpu_type=arm endian=little ;;
hppa*) cpu_type=hppa ;;
changequote(,)dnl
i[3456]86) cpu_type=i386 arch=i386;;

View File

@ -25,7 +25,7 @@ case "${host}" in
# Older versions of gcc do not use a specs file. In those cases,
# gcc -print-file-name=specs will simply print specs. We create a
# dummy specs files to handle this.
echo "-dynamic-linker `${CC} --print-file-name=ld-elf.so.1`" > specs
echo "-dynamic-linker `${CC} --print-prog-name=ld-elf.so.1`" > specs
HOSTING_CRT0='-dynamic-linker `${CC} --print-file-name=ld-elf.so.1` `${CC} --print-file-name=crt1.o` `${CC} --print-file-name=crti.o` `${CC} --print-file-name=crtbegin.o`'
HOSTING_LIBS='-L`dirname \`${CC} --print-file-name=libc.so\`` '"$HOSTING_LIBS"' `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else ${CC} --print-file-name=crtend.o; fi` `${CC} --print-file-name=crtn.o`'
;;

View File

@ -491,8 +491,16 @@ fr30-*-*) targ_emul=elf32fr30 ;;
mcore-*-pe) targ_emul=mcorepe ;
targ_extra_ofiles="deffilep.o pe-dll.o" ;;
mcore-*-elf) targ_emul=elf32mcore ;;
s390x-*-linux*) targ_emul=elf64_s390 ;;
s390-*-linux*) targ_emul=elf_s390 ;;
s390x-*-linux*) targ_emul=elf64_s390
targ_extra_emuls=elf_s390
targ_extra_libpath=$targ_extra_emuls
tdir_elf_s390=`echo ${targ_alias} | sed -e 's/s390x/s390/'` ;;
s390-*-linux*) targ_emul=elf_s390
if test "${want64}" = "true"; then
targ_extra_emuls=elf64_s390
targ_extra_libpath=$targ_extra_emuls
tdir_elf64_s390=`echo ${targ_alias} | sed -e 's/s390/s390x/'`
fi ;;
*-*-ieee*) targ_emul=vanilla ;;
*)

View File

@ -1,4 +1,4 @@
.\" Automatically generated by Pod::Man v1.3, Pod::Parser v1.13
.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
@ -21,7 +21,6 @@
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
@ -129,10 +128,9 @@
.\" ========================================================================
.\"
.IX Title "LD 1"
.TH LD 1 "2002-08-05" "binutils-2.12.91" "GNU Development Tools"
.UC
.TH LD 1 "2002-10-30" "binutils-2.13" "GNU Development Tools"
.SH "NAME"
ld \- Using \s-1LD\s0, the \s-1GNU\s0 linker
ld \- Using LD, the GNU linker
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
ld [\fBoptions\fR] \fIobjfile\fR ...
@ -177,6 +175,7 @@ link a file \f(CW\*(C`hello.o\*(C'\fR:
.Vb 1
\& ld -o <output> /lib/crt0.o hello.o -lc
.Ve
.PP
This tells \fBld\fR to produce a file called \fIoutput\fR as the
result of linking the file \f(CW\*(C`/lib/crt0.o\*(C'\fR with \f(CW\*(C`hello.o\*(C'\fR and
the library \f(CW\*(C`libc.a\*(C'\fR, which will come from the standard search
@ -242,6 +241,7 @@ compiler driver) like this:
.Vb 1
\& gcc -Wl,--startgroup foo.o bar.o -Wl,--endgroup
.Ve
.PP
This is important, because otherwise the compiler driver program may
silently drop the linker options, resulting in a bad link.
.PP
@ -958,6 +958,11 @@ shared libraries is normal since the kernel patches them at load time to
select which function is most appropriate for the current architecture.
I.E. dynamically select an appropriate memset function. Apparently it
is also normal for \s-1HPPA\s0 shared libraries to have undefined symbols.
.IP "\fB\-\-no\-undefined\-version\fR" 4
.IX Item "--no-undefined-version"
Normally when a symbol has an undefined version, the linker will ignore
it. This option disallows symbols with undefined version and a fatal error
will be issued instead.
.IP "\fB\-\-no\-warn\-mismatch\fR" 4
.IX Item "--no-warn-mismatch"
Normally \fBld\fR will give an error if you try to link together input
@ -1350,6 +1355,7 @@ Here is a trivial example:
\& return __real_malloc (c);
\& }
.Ve
.Sp
If you link other code with this file using \fB\-\-wrap malloc\fR, then
all calls to \f(CW\*(C`malloc\*(C'\fR will call the function \f(CW\*(C`_\|_wrap_malloc\*(C'\fR
instead. The call to \f(CW\*(C`_\|_real_malloc\*(C'\fR in \f(CW\*(C`_\|_wrap_malloc\*(C'\fR will
@ -1566,6 +1572,7 @@ a variable, or b) make the 'constant' index a variable. Thus:
\& extern_array[1] -->
\& { volatile type *t=extern_array; t[1] }
.Ve
.Sp
or
.Sp
.Vb 3
@ -1573,6 +1580,7 @@ or
\& extern_array[1] -->
\& { volatile int t=1; extern_array[t] }
.Ve
.Sp
For structs (and most other multiword data types) the only option
is to make the struct itself (or the long long, or the ...) variable:
.Sp
@ -1581,6 +1589,7 @@ is to make the struct itself (or the long long, or the ...) variable:
\& extern_struct.field -->
\& { volatile struct s *t=&extern_struct; t->field }
.Ve
.Sp
or
.Sp
.Vb 3
@ -1588,6 +1597,7 @@ or
\& extern_ll -->
\& { volatile long long * local_ll=&extern_ll; *local_ll }
.Ve
.Sp
A second method of dealing with this difficulty is to abandon
\&'auto\-import' for the offending symbol and mark it with
\&\f(CW\*(C`_\|_declspec(dllimport)\*(C'\fR. However, in practice that
@ -1608,6 +1618,7 @@ Original:
\& printf("%d\en",arr[1]);
\& }
.Ve
.Sp
Solution 1:
.Sp
.Vb 9
@ -1621,6 +1632,7 @@ Solution 1:
\& printf("%d\en",parr[1]);
\& }
.Ve
.Sp
Solution 2:
.Sp
.Vb 14
@ -1639,6 +1651,7 @@ Solution 2:
\& printf("%d\en",arr[1]);
\& }
.Ve
.Sp
A third way to avoid this problem is to re-code your
library to use a functional interface rather than a data interface
for the offending variables (e.g. \fIset_foo()\fR and \fIget_foo()\fR accessor