Lines 172-177
Link Here
|
172 |
elf_hash_table (info)->eh_info.hdr_sec = s; |
172 |
elf_hash_table (info)->eh_info.hdr_sec = s; |
173 |
} |
173 |
} |
174 |
|
174 |
|
|
|
175 |
if ( info->direct && !info->executable ) |
176 |
{ |
177 |
s = bfd_make_section (abfd, ".suse.direct"); |
178 |
if (s == NULL |
179 |
|| ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) |
180 |
|| ! bfd_set_section_alignment (abfd, s, 2)) |
181 |
return FALSE; |
182 |
elf_hash_table (info)->direct_sec = s; |
183 |
} |
184 |
|
175 |
/* Create sections to hold version informations. These are removed |
185 |
/* Create sections to hold version informations. These are removed |
176 |
if they are not needed. */ |
186 |
if they are not needed. */ |
177 |
s = bfd_make_section (abfd, ".gnu.version_d"); |
187 |
s = bfd_make_section (abfd, ".gnu.version_d"); |
Lines 2193-2199
Link Here
|
2193 |
|
2203 |
|
2194 |
return TRUE; |
2204 |
return TRUE; |
2195 |
} |
2205 |
} |
|
|
2206 |
|
2196 |
|
2207 |
|
|
|
2208 |
|
2197 |
/* Fix up the flags for a symbol. This handles various cases which |
2209 |
/* Fix up the flags for a symbol. This handles various cases which |
2198 |
can only be fixed after all the input files are seen. This is |
2210 |
can only be fixed after all the input files are seen. This is |
2199 |
currently called by both adjust_dynamic_symbol and |
2211 |
currently called by both adjust_dynamic_symbol and |
Lines 2848-2853
Link Here
|
2848 |
|
2860 |
|
2849 |
if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex)) |
2861 |
if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex)) |
2850 |
return -1; |
2862 |
return -1; |
|
|
2863 |
elf_dt_needed_idx (abfd) = ++(info->dt_needed_index); |
2864 |
/* fprintf (stderr, "Set soname '%s' as index %d\n", |
2865 |
soname, info->dt_needed_index); */ |
2851 |
} |
2866 |
} |
2852 |
else |
2867 |
else |
2853 |
/* We were just checking for existence of the tag. */ |
2868 |
/* We were just checking for existence of the tag. */ |
Lines 3143-3148
Link Here
|
3143 |
bfd_boolean add_needed; |
3158 |
bfd_boolean add_needed; |
3144 |
struct elf_link_hash_table * hash_table; |
3159 |
struct elf_link_hash_table * hash_table; |
3145 |
bfd_size_type amt; |
3160 |
bfd_size_type amt; |
|
|
3161 |
asection *direct_sec; |
3162 |
unsigned char *direct_data; |
3146 |
|
3163 |
|
3147 |
hash_table = elf_hash_table (info); |
3164 |
hash_table = elf_hash_table (info); |
3148 |
|
3165 |
|
Lines 3150-3155
Link Here
|
3150 |
add_symbol_hook = bed->elf_add_symbol_hook; |
3167 |
add_symbol_hook = bed->elf_add_symbol_hook; |
3151 |
collect = bed->collect; |
3168 |
collect = bed->collect; |
3152 |
|
3169 |
|
|
|
3170 |
direct_sec = NULL; |
3171 |
direct_data = NULL; |
3172 |
|
3153 |
if ((abfd->flags & DYNAMIC) == 0) |
3173 |
if ((abfd->flags & DYNAMIC) == 0) |
3154 |
dynamic = FALSE; |
3174 |
dynamic = FALSE; |
3155 |
else |
3175 |
else |
Lines 3169-3174
Link Here
|
3169 |
bfd_set_error (bfd_error_wrong_format); |
3189 |
bfd_set_error (bfd_error_wrong_format); |
3170 |
goto error_return; |
3190 |
goto error_return; |
3171 |
} |
3191 |
} |
|
|
3192 |
if (info->direct && |
3193 |
(direct_sec = bfd_get_section_by_name (abfd, ".suse.direct"))) |
3194 |
{ |
3195 |
direct_data = bfd_alloc (abfd, direct_sec->size); |
3196 |
if (direct_data == NULL || |
3197 |
! bfd_get_section_contents (abfd, direct_sec, direct_data, 0, direct_sec->size)) |
3198 |
goto error_return; |
3199 |
} |
3172 |
} |
3200 |
} |
3173 |
|
3201 |
|
3174 |
/* As a GNU extension, any input sections which are named |
3202 |
/* As a GNU extension, any input sections which are named |
Lines 3817-3822
Link Here
|
3817 |
&& vernum > 1 |
3845 |
&& vernum > 1 |
3818 |
&& definition) |
3846 |
&& definition) |
3819 |
h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1]; |
3847 |
h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1]; |
|
|
3848 |
|
3849 |
if (direct_sec) |
3850 |
{ |
3851 |
unsigned long d_idx = isym - isymbuf; |
3852 |
/* FIXME: does bfd_elf_get_elf_syms read dynsym or the symbol |
3853 |
table ? */ |
3854 |
d_idx += extsymoff; |
3855 |
d_idx *= 2; |
3856 |
if (d_idx > bfd_get_section_size (direct_sec)) |
3857 |
fprintf (stderr, "Warning - strange error on '%s': 0x%x 0x%x\n", |
3858 |
h->root.root.string, (int)d_idx, |
3859 |
(int)bfd_get_section_size (direct_sec)); |
3860 |
else |
3861 |
{ |
3862 |
unsigned int direct_entry; |
3863 |
direct_entry = bfd_get_16 (abfd, direct_data + d_idx); |
3864 |
if ((direct_entry & DT_SUSE_DIRECT_VAGUE)) |
3865 |
h->vague_ref = 1; |
3866 |
if (!h->vague_ref && |
3867 |
(direct_entry & DT_SUSE_DIRECT_MASK) != DT_SUSE_DIRECT_UNKNOWN) |
3868 |
h->concrete_ref = 1; |
3869 |
#if 0 |
3870 |
fprintf (stderr, "symbol '%s': %s direct entry 0x%x (index %d) section '%s' : '%s'\n", |
3871 |
h->root.root.string, |
3872 |
h->vague_ref ? "vague " : h->concrete_ref ? "concrete" : "unknown", |
3873 |
direct_entry, (int)d_idx/2, |
3874 |
new_sec ? new_sec->name : "<nosec>", |
3875 |
new_sec && new_sec->owner ? new_sec->owner->filename : "<noownername>"); |
3876 |
#endif |
3877 |
} |
3878 |
} |
3820 |
} |
3879 |
} |
3821 |
|
3880 |
|
3822 |
if (! (_bfd_generic_link_add_one_symbol |
3881 |
if (! (_bfd_generic_link_add_one_symbol |
Lines 3830-3835
Link Here
|
3830 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
3889 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
3831 |
*sym_hash = h; |
3890 |
*sym_hash = h; |
3832 |
|
3891 |
|
|
|
3892 |
/* FIXME: move direct bits here ? - seem fine where they are ... */ |
3893 |
|
3833 |
new_weakdef = FALSE; |
3894 |
new_weakdef = FALSE; |
3834 |
if (dynamic |
3895 |
if (dynamic |
3835 |
&& definition |
3896 |
&& definition |
Lines 4450-4455
Link Here
|
4450 |
if (isymbuf != NULL) |
4511 |
if (isymbuf != NULL) |
4451 |
free (isymbuf); |
4512 |
free (isymbuf); |
4452 |
error_return: |
4513 |
error_return: |
|
|
4514 |
if (direct_data != NULL) |
4515 |
free (direct_data); |
4453 |
return FALSE; |
4516 |
return FALSE; |
4454 |
} |
4517 |
} |
4455 |
|
4518 |
|
Lines 5671-5676
Link Here
|
5671 |
return FALSE; |
5734 |
return FALSE; |
5672 |
} |
5735 |
} |
5673 |
|
5736 |
|
|
|
5737 |
/* Create the direct bindings section - 1 entry per dynsym */ |
5738 |
s = bfd_get_section_by_name (dynobj, ".direct"); |
5739 |
if (s) |
5740 |
{ |
5741 |
if (dynsymcount == 0) |
5742 |
s->flags |= SEC_EXCLUDE; |
5743 |
else |
5744 |
{ |
5745 |
s->size = dynsymcount * sizeof (Elf_External_Direct); |
5746 |
s->contents = bfd_zalloc (output_bfd, s->size); |
5747 |
if (s->contents == NULL) |
5748 |
return FALSE; |
5749 |
memset (s->contents, 0xff, s->size); |
5750 |
if (!_bfd_elf_add_dynamic_entry (info, DT_SUSE_DIRECT, 0)) |
5751 |
return FALSE; |
5752 |
} |
5753 |
} |
5754 |
|
5674 |
/* Set the size of the .dynsym and .hash sections. We counted |
5755 |
/* Set the size of the .dynsym and .hash sections. We counted |
5675 |
the number of dynamic symbols in elf_link_add_object_symbols. |
5756 |
the number of dynamic symbols in elf_link_add_object_symbols. |
5676 |
We will build the contents of .dynsym and .hash when we build |
5757 |
We will build the contents of .dynsym and .hash when we build |
Lines 5749-5754
Link Here
|
5749 |
asection *hash_sec; |
5830 |
asection *hash_sec; |
5750 |
/* symbol version section (.gnu.version). */ |
5831 |
/* symbol version section (.gnu.version). */ |
5751 |
asection *symver_sec; |
5832 |
asection *symver_sec; |
|
|
5833 |
/* .direct linkage section */ |
5834 |
asection *direct_sec; |
5752 |
/* Buffer large enough to hold contents of any section. */ |
5835 |
/* Buffer large enough to hold contents of any section. */ |
5753 |
bfd_byte *contents; |
5836 |
bfd_byte *contents; |
5754 |
/* Buffer large enough to hold external relocs of any section. */ |
5837 |
/* Buffer large enough to hold external relocs of any section. */ |
Lines 6603-6608
Link Here
|
6603 |
eversym += h->dynindx; |
6704 |
eversym += h->dynindx; |
6604 |
_bfd_elf_swap_versym_out (finfo->output_bfd, &iversym, eversym); |
6705 |
_bfd_elf_swap_versym_out (finfo->output_bfd, &iversym, eversym); |
6605 |
} |
6706 |
} |
|
|
6707 |
|
6708 |
if (finfo->direct_sec) |
6709 |
{ |
6710 |
bfd_vma offset = 2 * h->dynindx; |
6711 |
if (offset > finfo->direct_sec->size) |
6712 |
fprintf (stderr, "Out of bounds direct section index %d\n", |
6713 |
(int) offset); |
6714 |
else |
6715 |
{ |
6716 |
int dt_index = DT_SUSE_DIRECT_UNKNOWN; |
6717 |
|
6718 |
#if 0 |
6719 |
fprintf (stderr, "Symbol '%s' type %d\n", |
6720 |
h->root.root.string, h->root.type); |
6721 |
#endif |
6722 |
if ((h->root.type == bfd_link_hash_defined |
6723 |
|| h->root.type == bfd_link_hash_defweak) && |
6724 |
h->root.u.def.section != NULL && |
6725 |
h->root.u.def.section->owner != NULL) |
6726 |
|
6727 |
{ |
6728 |
asection *sec = h->root.u.def.section; |
6729 |
|
6730 |
dt_index = elf_dt_needed_idx (sec->owner); |
6731 |
|
6732 |
if (!(sec->owner->flags & DYNAMIC)) |
6733 |
{ |
6734 |
if (!sec->name || |
6735 |
!strncmp (sec->name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1)) |
6736 |
dt_index |= DT_SUSE_DIRECT_VAGUE; |
6737 |
|
6738 |
/* app -> library data references get turned into copy |
6739 |
relocs, so objects can migrate unpredictably into the |
6740 |
application itself. */ |
6741 |
else if (h->type == STT_OBJECT) |
6742 |
dt_index |= DT_SUSE_DIRECT_VAGUE; |
6743 |
} |
6744 |
else if (h->vague_ref) |
6745 |
dt_index |= DT_SUSE_DIRECT_VAGUE; |
6746 |
|
6747 |
else if (!h->concrete_ref) |
6748 |
dt_index = DT_SUSE_DIRECT_UNKNOWN; |
6749 |
|
6750 |
#if 0 |
6751 |
fprintf (stderr, "Sym '%s' (type %d) [type %d] section %s [%s] owner '%s' [%d] offset %d resolves '%s'\n", |
6752 |
h->root.root.string, h->root.type, h->type, |
6753 |
sec->name ? sec->name : "<null>", |
6754 |
sec->owner->flags & DYNAMIC ? "dynamic" : "static", |
6755 |
sec->owner ? sec->owner->filename : "<noowner?>", |
6756 |
dt_index, (int) offset, |
6757 |
dt_index & DT_SUSE_DIRECT_VAGUE ? "<vague>" : "concrete"); |
6758 |
#endif |
6759 |
} |
6760 |
bfd_put_16 (finfo->output_bfd, |
6761 |
dt_index, |
6762 |
finfo->direct_sec->contents + offset); |
6763 |
} |
6764 |
} |
6606 |
} |
6765 |
} |
6607 |
|
6766 |
|
6608 |
/* If we're stripping it, then it was just a dynamic symbol, and |
6767 |
/* If we're stripping it, then it was just a dynamic symbol, and |
Lines 7732-7737
Link Here
|
7732 |
|
7891 |
|
7733 |
if (! dynamic) |
7892 |
if (! dynamic) |
7734 |
{ |
7893 |
{ |
|
|
7894 |
finfo.direct_sec = NULL; |
7735 |
finfo.dynsym_sec = NULL; |
7895 |
finfo.dynsym_sec = NULL; |
7736 |
finfo.hash_sec = NULL; |
7896 |
finfo.hash_sec = NULL; |
7737 |
finfo.symver_sec = NULL; |
7897 |
finfo.symver_sec = NULL; |
Lines 7740-7745
Link Here
|
7740 |
} |
7900 |
} |
7741 |
else |
7901 |
else |
7742 |
{ |
7902 |
{ |
|
|
7903 |
finfo.direct_sec = bfd_get_section_by_name (dynobj, ".suse.direct"); |
7743 |
finfo.dynsym_sec = bfd_get_section_by_name (dynobj, ".dynsym"); |
7904 |
finfo.dynsym_sec = bfd_get_section_by_name (dynobj, ".dynsym"); |
7744 |
finfo.hash_sec = bfd_get_section_by_name (dynobj, ".hash"); |
7905 |
finfo.hash_sec = bfd_get_section_by_name (dynobj, ".hash"); |
7745 |
BFD_ASSERT (finfo.dynsym_sec != NULL && finfo.hash_sec != NULL); |
7906 |
BFD_ASSERT (finfo.dynsym_sec != NULL && finfo.hash_sec != NULL); |
Lines 8492-8497
Link Here
|
8492 |
case DT_VERNEED: |
8653 |
case DT_VERNEED: |
8493 |
name = ".gnu.version_r"; |
8654 |
name = ".gnu.version_r"; |
8494 |
goto get_vma; |
8655 |
goto get_vma; |
|
|
8656 |
case DT_SUSE_DIRECT: |
8657 |
name = ".suse.direct"; |
8658 |
goto get_vma; |
8495 |
case DT_VERSYM: |
8659 |
case DT_VERSYM: |
8496 |
name = ".gnu.version"; |
8660 |
name = ".gnu.version"; |
8497 |
get_vma: |
8661 |
get_vma: |