GOLD LINKER DYNAMIC TABLE ISSUE
Takis Psarogiannakopoulos
takis@XFree86.Org
Sun Dec 13 03:27:00 GMT 2009
On Fri, 11 Dec 2009, Ian Lance Taylor wrote:
>
> Note that gold doesn't use BFD.
>
OK I ve made some modifications on the gold/dynobj.cc in
template<int size, bool big_endian>
void
Sized_dynobj<size, big_endian>::find_dynsym_sections
.....
+ const unsigned char* q = pshdrs;
+ unsigned int has_sht_dynsym = 0;
+
+ // Our dynamic object has a valid dynamic symbol table ?
+ for (unsigned int k = 0; k < shnum; ++k, q += This::shdr_size)
+ {
+ typename This::Shdr shdr(q);
+ switch (shdr.get_sh_type())
+ {
+ case elfcpp::SHT_DYNSYM:
+ has_sht_dynsym = 1;
+ break;
+ default:
+ break;
+ }
+ }
+#ifdef DEBUG
+ printf(" Dynamic Symbol Table is set to %d\n", has_sht_dynsym);
+#endif
for (unsigned int i = 0; i < shnum; ++i, p += This::shdr_size)
{
typename This::Shdr shdr(p);
unsigned int* pi;
switch (shdr.get_sh_type())
{
case elfcpp::SHT_DYNSYM:
+ if (has_sht_dynsym == 1)
+ {
+#ifdef DEBUG
+ printf("Using valid Dynamic Symbol Table\n");
+#endif
this->dynsym_shndx_ = i;
if (xindex_shndx > 0 && xindex_link == i)
{
Xindex* xindex = new
Xindex(this->elf_file_.large_shndx_offset());
xindex->read_symtab_xindex<size, big_endian>(this,
xindex_shndx,
pshdrs);
this->set_xindex(xindex);
}
+ }
pi = NULL;
break;
+ case elfcpp::SHT_SYMTAB:
+ if (has_sht_dynsym == 0)
+ {
+#ifdef DEBUG
+ printf("Using the Normal Symbol Table\n");
+#endif
+ this->dynsym_shndx_ = i;
+ if (xindex_shndx > 0 && xindex_link == i)
+ {
+ Xindex* xindex = new
+ Xindex(this->elf_file_.large_shndx_offset());
+ xindex->read_symtab_xindex<size, big_endian>(this,
+ xindex_shndx,
+ pshdrs);
+ this->set_xindex(xindex);
+ }
+ }
+ pi = NULL;
+ break;
case elfcpp::SHT_GNU_versym:
..............
Basically because I am not sure how SHT_SYMTAB and SHT_DYNSYM are
appearing and in what order I am running the loop to find if there is a
valid dynamic symbol table and then I enforce it keeping the initial
switch. I know better ways to write that but I need clarifications on the
rest of the switch elements so for the time being looks the safest way.
Regards,
More information about the Binutils
mailing list