Lines 194-199
Link Here
|
194 |
elf_hash_table (info)->eh_info.hdr_sec = s; |
194 |
elf_hash_table (info)->eh_info.hdr_sec = s; |
195 |
} |
195 |
} |
196 |
|
196 |
|
|
|
197 |
if ( info->direct && !info->executable ) |
198 |
{ |
199 |
s = bfd_make_section (abfd, ".direct"); |
200 |
if (s == NULL |
201 |
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) |
202 |
|| ! bfd_set_section_alignment (abfd, s, 2)) |
203 |
return FALSE; |
204 |
elf_hash_table (info)->direct_sec = s; |
205 |
} |
206 |
|
197 |
/* Create sections to hold version informations. These are removed |
207 |
/* Create sections to hold version informations. These are removed |
198 |
if they are not needed. */ |
208 |
if they are not needed. */ |
199 |
s = bfd_make_section_with_flags (abfd, ".gnu.version_d", |
209 |
s = bfd_make_section_with_flags (abfd, ".gnu.version_d", |
Lines 2844-2849
Link Here
|
2844 |
|
2854 |
|
2845 |
if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex)) |
2855 |
if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex)) |
2846 |
return -1; |
2856 |
return -1; |
|
|
2857 |
elf_dt_needed_idx (abfd) = ++(info->dt_needed_index); |
2858 |
/* fprintf (stderr, "Set soname '%s' as index %d\n", |
2859 |
soname, info->dt_needed_index); */ |
2847 |
} |
2860 |
} |
2848 |
else |
2861 |
else |
2849 |
/* We were just checking for existence of the tag. */ |
2862 |
/* We were just checking for existence of the tag. */ |
Lines 3139-3144
Link Here
|
3139 |
bfd_boolean add_needed; |
3152 |
bfd_boolean add_needed; |
3140 |
struct elf_link_hash_table * hash_table; |
3153 |
struct elf_link_hash_table * hash_table; |
3141 |
bfd_size_type amt; |
3154 |
bfd_size_type amt; |
|
|
3155 |
asection *direct_sec; |
3156 |
unsigned char *direct_data; |
3142 |
|
3157 |
|
3143 |
hash_table = elf_hash_table (info); |
3158 |
hash_table = elf_hash_table (info); |
3144 |
|
3159 |
|
Lines 3146-3151
Link Here
|
3146 |
add_symbol_hook = bed->elf_add_symbol_hook; |
3161 |
add_symbol_hook = bed->elf_add_symbol_hook; |
3147 |
collect = bed->collect; |
3162 |
collect = bed->collect; |
3148 |
|
3163 |
|
|
|
3164 |
direct_sec = NULL; |
3165 |
direct_data = NULL; |
3166 |
|
3149 |
if ((abfd->flags & DYNAMIC) == 0) |
3167 |
if ((abfd->flags & DYNAMIC) == 0) |
3150 |
dynamic = FALSE; |
3168 |
dynamic = FALSE; |
3151 |
else |
3169 |
else |
Lines 3165-3170
Link Here
|
3165 |
bfd_set_error (bfd_error_wrong_format); |
3183 |
bfd_set_error (bfd_error_wrong_format); |
3166 |
goto error_return; |
3184 |
goto error_return; |
3167 |
} |
3185 |
} |
|
|
3186 |
if (info->direct && |
3187 |
(direct_sec = bfd_get_section_by_name (abfd, ".direct"))) |
3188 |
{ |
3189 |
direct_data = bfd_alloc (abfd, direct_sec->size); |
3190 |
if (direct_data == NULL || |
3191 |
! bfd_get_section_contents (abfd, direct_sec, direct_data, 0, direct_sec->size)) |
3192 |
goto error_return; |
3193 |
} |
3168 |
} |
3194 |
} |
3169 |
|
3195 |
|
3170 |
/* As a GNU extension, any input sections which are named |
3196 |
/* As a GNU extension, any input sections which are named |
Lines 3814-3819
Link Here
|
3814 |
&& vernum > 1 |
3840 |
&& vernum > 1 |
3815 |
&& definition) |
3841 |
&& definition) |
3816 |
h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1]; |
3842 |
h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1]; |
|
|
3843 |
|
3844 |
if (direct_sec) |
3845 |
{ |
3846 |
unsigned long d_idx = isym - isymbuf; |
3847 |
/* FIXME: does bfd_elf_get_elf_syms read dynsym or the symbol |
3848 |
table ? */ |
3849 |
d_idx += extsymoff; |
3850 |
d_idx *= 2; |
3851 |
if (d_idx > bfd_get_section_size (direct_sec)) |
3852 |
fprintf (stderr, "Warning - strange error on '%s': 0x%x 0x%x\n", |
3853 |
h->root.root.string, (int)d_idx, |
3854 |
(int)bfd_get_section_size (direct_sec)); |
3855 |
else |
3856 |
{ |
3857 |
unsigned int direct_entry; |
3858 |
direct_entry = bfd_get_16 (abfd, direct_data + d_idx); |
3859 |
if ((direct_entry & DT_DIRECT_VAGUE)) |
3860 |
h->vague_ref = 1; |
3861 |
if (!h->vague_ref && |
3862 |
(direct_entry & DT_DIRECT_MASK) != DT_DIRECT_UNKNOWN) |
3863 |
h->concrete_ref = 1; |
3864 |
#if 0 |
3865 |
fprintf (stderr, "symbol '%s': %s direct entry 0x%x (index %d) section '%s' : '%s'\n", |
3866 |
h->root.root.string, |
3867 |
h->vague_ref ? "vague " : h->concrete_ref ? "concrete" : "unknown", |
3868 |
direct_entry, (int)d_idx/2, |
3869 |
new_sec ? new_sec->name : "<nosec>", |
3870 |
new_sec && new_sec->owner ? new_sec->owner->filename : "<noownername>"); |
3871 |
#endif |
3872 |
} |
3873 |
} |
3817 |
} |
3874 |
} |
3818 |
|
3875 |
|
3819 |
if (! (_bfd_generic_link_add_one_symbol |
3876 |
if (! (_bfd_generic_link_add_one_symbol |
Lines 3827-3832
Link Here
|
3827 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
3884 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
3828 |
*sym_hash = h; |
3885 |
*sym_hash = h; |
3829 |
|
3886 |
|
|
|
3887 |
/* FIXME: move direct bits here ? - seem fine where they are ... */ |
3888 |
|
3830 |
new_weakdef = FALSE; |
3889 |
new_weakdef = FALSE; |
3831 |
if (dynamic |
3890 |
if (dynamic |
3832 |
&& definition |
3891 |
&& definition |
Lines 4446-4451
Link Here
|
4446 |
if (isymbuf != NULL) |
4505 |
if (isymbuf != NULL) |
4447 |
free (isymbuf); |
4506 |
free (isymbuf); |
4448 |
error_return: |
4507 |
error_return: |
|
|
4508 |
if (direct_data != NULL) |
4509 |
free (direct_data); |
4449 |
return FALSE; |
4510 |
return FALSE; |
4450 |
} |
4511 |
} |
4451 |
|
4512 |
|
Lines 5695-5700
Link Here
|
5695 |
return FALSE; |
5756 |
return FALSE; |
5696 |
} |
5757 |
} |
5697 |
|
5758 |
|
|
|
5759 |
/* Create the direct bindings section - 1 entry per dynsym */ |
5760 |
s = bfd_get_section_by_name (dynobj, ".direct"); |
5761 |
if (s) |
5762 |
{ |
5763 |
if (dynsymcount == 0) |
5764 |
// _bfd_strip_section_from_output (info, s); |
5765 |
else |
5766 |
{ |
5767 |
s->size = dynsymcount * sizeof (Elf_External_Direct); |
5768 |
s->contents = bfd_zalloc (output_bfd, s->size); |
5769 |
if (s->contents == NULL) |
5770 |
return FALSE; |
5771 |
memset (s->contents, 0xff, s->size); |
5772 |
if (!_bfd_elf_add_dynamic_entry (info, DT_DIRECT, 0)) |
5773 |
return FALSE; |
5774 |
} |
5775 |
} |
5776 |
|
5698 |
/* Set the size of the .dynsym and .hash sections. We counted |
5777 |
/* Set the size of the .dynsym and .hash sections. We counted |
5699 |
the number of dynamic symbols in elf_link_add_object_symbols. |
5778 |
the number of dynamic symbols in elf_link_add_object_symbols. |
5700 |
We will build the contents of .dynsym and .hash when we build |
5779 |
We will build the contents of .dynsym and .hash when we build |
Lines 5769-5774
Link Here
|
5769 |
asection *hash_sec; |
5848 |
asection *hash_sec; |
5770 |
/* symbol version section (.gnu.version). */ |
5849 |
/* symbol version section (.gnu.version). */ |
5771 |
asection *symver_sec; |
5850 |
asection *symver_sec; |
|
|
5851 |
/* .direct linkage section */ |
5852 |
asection *direct_sec; |
5772 |
/* Buffer large enough to hold contents of any section. */ |
5853 |
/* Buffer large enough to hold contents of any section. */ |
5773 |
bfd_byte *contents; |
5854 |
bfd_byte *contents; |
5774 |
/* Buffer large enough to hold external relocs of any section. */ |
5855 |
/* Buffer large enough to hold external relocs of any section. */ |
Lines 6625-6630
Link Here
|
6625 |
eversym += h->dynindx; |
6706 |
eversym += h->dynindx; |
6626 |
_bfd_elf_swap_versym_out (finfo->output_bfd, &iversym, eversym); |
6707 |
_bfd_elf_swap_versym_out (finfo->output_bfd, &iversym, eversym); |
6627 |
} |
6708 |
} |
|
|
6709 |
|
6710 |
if (finfo->direct_sec) |
6711 |
{ |
6712 |
bfd_vma offset = 2 * h->dynindx; |
6713 |
if (offset > finfo->direct_sec->size) |
6714 |
fprintf (stderr, "Out of bounds direct section index %d\n", |
6715 |
(int) offset); |
6716 |
else |
6717 |
{ |
6718 |
int dt_index = DT_DIRECT_UNKNOWN; |
6719 |
|
6720 |
#if 0 |
6721 |
fprintf (stderr, "Symbol '%s' type %d\n", |
6722 |
h->root.root.string, h->root.type); |
6723 |
#endif |
6724 |
if ((h->root.type == bfd_link_hash_defined |
6725 |
|| h->root.type == bfd_link_hash_defweak) && |
6726 |
h->root.u.def.section != NULL && |
6727 |
h->root.u.def.section->owner != NULL) |
6728 |
|
6729 |
{ |
6730 |
asection *sec = h->root.u.def.section; |
6731 |
|
6732 |
dt_index = elf_dt_needed_idx (sec->owner); |
6733 |
|
6734 |
if (!(sec->owner->flags & DYNAMIC)) |
6735 |
{ |
6736 |
if (!sec->name || |
6737 |
!strncmp (sec->name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1)) |
6738 |
dt_index |= DT_DIRECT_VAGUE; |
6739 |
|
6740 |
/* app -> library data references get turned into copy |
6741 |
relocs, so objects can migrate unpredictably into the |
6742 |
application itself. */ |
6743 |
else if (h->type == STT_OBJECT) |
6744 |
dt_index |= DT_DIRECT_VAGUE; |
6745 |
} |
6746 |
else if (h->vague_ref) |
6747 |
dt_index |= DT_DIRECT_VAGUE; |
6748 |
|
6749 |
else if (!h->concrete_ref) |
6750 |
dt_index = DT_DIRECT_UNKNOWN; |
6751 |
|
6752 |
#if 0 |
6753 |
fprintf (stderr, "Sym '%s' (type %d) [type %d] section %s [%s] owner '%s' [%d] offset %d resolves '%s'\n", |
6754 |
h->root.root.string, h->root.type, h->type, |
6755 |
sec->name ? sec->name : "<null>", |
6756 |
sec->owner->flags & DYNAMIC ? "dynamic" : "static", |
6757 |
sec->owner ? sec->owner->filename : "<noowner?>", |
6758 |
dt_index, (int) offset, |
6759 |
dt_index & DT_DIRECT_VAGUE ? "<vague>" : "concrete"); |
6760 |
#endif |
6761 |
} |
6762 |
bfd_put_16 (finfo->output_bfd, |
6763 |
dt_index, |
6764 |
finfo->direct_sec->contents + offset); |
6765 |
} |
6766 |
} |
6628 |
} |
6767 |
} |
6629 |
|
6768 |
|
6630 |
/* If we're stripping it, then it was just a dynamic symbol, and |
6769 |
/* If we're stripping it, then it was just a dynamic symbol, and |
Lines 7768-7773
Link Here
|
7768 |
finfo.dynsym_sec = NULL; |
7907 |
finfo.dynsym_sec = NULL; |
7769 |
finfo.hash_sec = NULL; |
7908 |
finfo.hash_sec = NULL; |
7770 |
finfo.symver_sec = NULL; |
7909 |
finfo.symver_sec = NULL; |
|
|
7910 |
finfo.direct_sec = NULL; |
7771 |
} |
7911 |
} |
7772 |
else |
7912 |
else |
7773 |
{ |
7913 |
{ |
Lines 7776-7781
Link Here
|
7776 |
BFD_ASSERT (finfo.dynsym_sec != NULL && finfo.hash_sec != NULL); |
7916 |
BFD_ASSERT (finfo.dynsym_sec != NULL && finfo.hash_sec != NULL); |
7777 |
finfo.symver_sec = bfd_get_section_by_name (dynobj, ".gnu.version"); |
7917 |
finfo.symver_sec = bfd_get_section_by_name (dynobj, ".gnu.version"); |
7778 |
/* Note that it is OK if symver_sec is NULL. */ |
7918 |
/* Note that it is OK if symver_sec is NULL. */ |
|
|
7919 |
finfo.direct_sec = bfd_get_section_by_name (dynobj, ".direct"); |
7779 |
} |
7920 |
} |
7780 |
|
7921 |
|
7781 |
finfo.contents = NULL; |
7922 |
finfo.contents = NULL; |
Lines 8527-8532
Link Here
|
8527 |
case DT_VERNEED: |
8668 |
case DT_VERNEED: |
8528 |
name = ".gnu.version_r"; |
8669 |
name = ".gnu.version_r"; |
8529 |
goto get_vma; |
8670 |
goto get_vma; |
|
|
8671 |
case DT_DIRECT: |
8672 |
name = ".direct"; |
8673 |
goto get_vma; |
8530 |
case DT_VERSYM: |
8674 |
case DT_VERSYM: |
8531 |
name = ".gnu.version"; |
8675 |
name = ".gnu.version"; |
8532 |
get_vma: |
8676 |
get_vma: |