This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix the list of directories searched for object files and libraries.


Without this patch, the following command is terminated due to an
invalid memory reference (SIGEGV):

    ld -m elf_i386 -L /opt/XXX/lib -lfoo bar.o

Technically, this is due to how the function "open_along_path2"
handles the list of directories searched for object files and
libraries:

    open_along_path2 ([...], pathelement *path)
    {
      [...]
      firstp = path;
      do
        {
          [...]
          path = path->next;
        }
      while ([...] && path != firstp));
      [...]
    }

The function "open_along_path2" assumes the field "next" of the last
element points to the first element.
---
 src/ld.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/ld.c b/src/ld.c
index 4f587fe..162cb1e 100644
--- a/src/ld.c
+++ b/src/ld.c
@@ -1189,6 +1189,9 @@ ld_new_searchdir (const char *dir)
       ld_state.tailpaths->next = newpath;
       ld_state.tailpaths = newpath;
     }
+
+  /* Update the last element according to open_along_path2's assumption.  */
+  ld_state.tailpaths->next = ld_state.paths;
 }
 
 
-- 
1.6.1

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]