1
1
/* Intel 80386/80486-specific support for 32-bit ELF
2
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3
Free Software Foundation, Inc.
2
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
3
2003, 2004 Free Software Foundation, Inc.
5
5
This file is part of BFD, the Binary File Descriptor library.
348
348
/* Support for core dump NOTE sections. */
349
350
static bfd_boolean
350
351
elf_i386_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
355
switch (note->descsz)
360
case 144: /* Linux/i386 */
362
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
365
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
356
if (note->namesz == 8 && strcmp (note->namedata, "FreeBSD") == 0)
358
int pr_version = bfd_get_32 (abfd, note->descdata);
364
elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 20);
367
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
371
raw_size = bfd_get_32 (abfd, note->descdata + 8);
375
switch (note->descsz)
380
case 144: /* Linux/i386 */
382
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
385
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
374
395
/* Make a ".reg/999" section. */
379
400
static bfd_boolean
380
401
elf_i386_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
382
switch (note->descsz)
403
if (note->namesz == 8 && strcmp (note->namedata, "FreeBSD") == 0)
405
int pr_version = bfd_get_32 (abfd, note->descdata);
387
case 124: /* Linux/i386 elf_prpsinfo */
388
elf_tdata (abfd)->core_program
389
= _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
390
elf_tdata (abfd)->core_command
391
= _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
410
elf_tdata (abfd)->core_program
411
= _bfd_elfcore_strndup (abfd, note->descdata + 8, 17);
412
elf_tdata (abfd)->core_command
413
= _bfd_elfcore_strndup (abfd, note->descdata + 25, 81);
417
switch (note->descsz)
422
case 124: /* Linux/i386 elf_prpsinfo. */
423
elf_tdata (abfd)->core_program
424
= _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
425
elf_tdata (abfd)->core_command
426
= _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
394
430
/* Note that for some reason, a spurious space is tacked
395
431
onto the end of the args in some (at least one anyway)
396
432
implementations, so strip it off if it exists. */
399
434
char *command = elf_tdata (abfd)->core_command;
400
435
int n = strlen (command);
550
elf_i386_object_p (bfd *abfd)
552
/* Allocate our special target data. */
553
struct elf_i386_obj_tdata *new_tdata;
554
bfd_size_type amt = sizeof (struct elf_i386_obj_tdata);
555
new_tdata = bfd_zalloc (abfd, amt);
556
if (new_tdata == NULL)
558
new_tdata->root = *abfd->tdata.elf_obj_data;
559
abfd->tdata.any = new_tdata;
563
584
/* i386 ELF linker hash table. */
565
586
struct elf_i386_link_hash_table
770
791
dir->elf_link_hash_flags |=
771
792
(ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
772
793
| ELF_LINK_HASH_REF_REGULAR
773
| ELF_LINK_HASH_REF_REGULAR_NONWEAK));
794
| ELF_LINK_HASH_REF_REGULAR_NONWEAK
795
| ELF_LINK_HASH_NEEDS_PLT
796
| ELF_LINK_POINTER_EQUALITY_NEEDED));
775
798
_bfd_elf_link_hash_copy_indirect (bed, dir, ind);
1000
1023
/* We may need a .plt entry if the function this reloc
1001
1024
refers to is in a shared lib. */
1002
1025
h->plt.refcount += 1;
1026
if (r_type != R_386_PC32)
1027
h->elf_link_hash_flags |= ELF_LINK_POINTER_EQUALITY_NEEDED;
1005
1030
/* If we are creating a shared library, and this is a reloc
1132
1157
/* This relocation describes the C++ object vtable hierarchy.
1133
1158
Reconstruct it for later use during GC. */
1134
1159
case R_386_GNU_VTINHERIT:
1135
if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
1160
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
1139
1164
/* This relocation describes which C++ vtable entries are actually
1140
1165
used. Record for later use during GC. */
1141
1166
case R_386_GNU_VTENTRY:
1142
if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
1167
if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
1436
/* This is the condition under which elf_i386_finish_dynamic_symbol
1437
will be called from elflink.h. If elflink.h doesn't call our
1438
finish_dynamic_symbol routine, we'll need to do something about
1439
initializing any .plt and .got entries in elf_i386_relocate_section. */
1440
#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
1443
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
1444
&& ((H)->dynindx != -1 \
1445
|| ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
1447
1461
/* Allocate space in .plt, .got and associated reloc sections for
1448
1462
dynamic relocs. */
1870
1884
the .dynamic section. The DT_DEBUG entry is filled in by the
1871
1885
dynamic linker and used by the debugger. */
1872
1886
#define add_dynamic_entry(TAG, VAL) \
1873
bfd_elf32_add_dynamic_entry (info, (TAG), (VAL))
1887
_bfd_elf_add_dynamic_entry (info, TAG, VAL)
1875
1889
if (info->executable)
1954
1968
dtpoff_base (struct bfd_link_info *info)
1956
/* If tls_segment is NULL, we should have signalled an error already. */
1957
if (elf_hash_table (info)->tls_segment == NULL)
1970
/* If tls_sec is NULL, we should have signalled an error already. */
1971
if (elf_hash_table (info)->tls_sec == NULL)
1959
return elf_hash_table (info)->tls_segment->start;
1973
return elf_hash_table (info)->tls_sec->vma;
1962
1976
/* Return the relocation value for @tpoff relocation
1966
1980
tpoff (struct bfd_link_info *info, bfd_vma address)
1968
struct elf_link_tls_segment *tls_segment
1969
= elf_hash_table (info)->tls_segment;
1982
struct elf_link_hash_table *htab = elf_hash_table (info);
1971
/* If tls_segment is NULL, we should have signalled an error already. */
1972
if (tls_segment == NULL)
1984
/* If tls_sec is NULL, we should have signalled an error already. */
1985
if (htab->tls_sec == NULL)
1974
return (align_power (tls_segment->size, tls_segment->align)
1975
+ tls_segment->start - address);
1987
return htab->tls_size + htab->tls_sec->vma - address;
1978
1990
/* Relocate an i386 ELF section. */
2157
2169
bfd_boolean warned;
2159
RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr, relocation, sec, unresolved_reloc, info, warned);
2171
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
2172
r_symndx, symtab_hdr, sym_hashes,
2174
unresolved_reloc, warned);
2162
2177
switch (r_type)
3005
3020
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
3007
3022
/* Mark the symbol as undefined, rather than as defined in
3008
the .plt section. Leave the value alone. This is a clue
3023
the .plt section. Leave the value if there were any
3024
relocations where pointer equality matters (this is a clue
3009
3025
for the dynamic linker, to make function pointer
3010
3026
comparisons work between an application and shared
3027
library), otherwise set it to zero. If a function is only
3028
called from a binary, there is no need to slow down
3029
shared libraries because of that. */
3012
3030
sym->st_shndx = SHN_UNDEF;
3031
if ((h->elf_link_hash_flags & ELF_LINK_POINTER_EQUALITY_NEEDED) == 0)
3240
3260
#define elf_backend_plt_readonly 1
3241
3261
#define elf_backend_want_plt_sym 0
3242
3262
#define elf_backend_got_header_size 12
3243
#define elf_backend_plt_header_size PLT_ENTRY_SIZE
3245
3264
/* Support RELA for objdump of prelink objects. */
3246
3265
#define elf_info_to_howto elf_i386_info_to_howto_rel
3247
3266
#define elf_info_to_howto_rel elf_i386_info_to_howto_rel
3249
3268
#define bfd_elf32_mkobject elf_i386_mkobject
3250
#define elf_backend_object_p elf_i386_object_p
3252
3270
#define bfd_elf32_bfd_is_local_label_name elf_i386_is_local_label_name
3253
3271
#define bfd_elf32_bfd_link_hash_table_create elf_i386_link_hash_table_create