diff options
author | H.J. Lu <hjl@lucon.org> | 2002-10-19 17:13:58 +0000 |
---|---|---|
committer | H.J. Lu <hjl@lucon.org> | 2002-10-19 17:13:58 +0000 |
commit | 36a1ab58dd87254f07561aa038d472fd9b1111d8 (patch) | |
tree | 56595b25bf352ef3d3afe943ea2b8c095b163c65 /bfd | |
parent | 3483c61ef68648efcf17d84d8107aaffcb62145b (diff) | |
download | gdb-36a1ab58dd87254f07561aa038d472fd9b1111d8.tar.gz |
2002-10-19 H.J. Lu <hjl@gnu.org>
* elflink.h (elf_link_add_object_symbols): Correctly handle
DT_RPATH and DT_RUNPATH.
:VS: ----------------------------------------------------------------------
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 5 | ||||
-rw-r--r-- | bfd/elflink.h | 34 |
2 files changed, 23 insertions, 16 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8f1d482799c..5ddc2ea8509 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2002-10-19 H.J. Lu <hjl@gnu.org> + + * elflink.h (elf_link_add_object_symbols): Correctly handle + DT_RPATH and DT_RUNPATH. + 2002-10-19 Mark Kettenis <kettenis@gnu.org> * elf.c (elfcore_grok_note): Fix recognition on NT_PRXFPREG notes. diff --git a/bfd/elflink.h b/bfd/elflink.h index 5e2acbd4926..079917ef75d 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -1298,6 +1298,7 @@ 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 @@ -1334,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) @@ -1352,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; @@ -1397,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); @@ -1417,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) @@ -1449,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 |