]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libbacktrace/elf.c
* config/i386/i386.md (and<mode>3): Generate zero-extends for
[thirdparty/gcc.git] / libbacktrace / elf.c
index 87e7b0d361d5414bfa68c1608178ee22cf5ed756..f3988ec02a05400b5631eea810589035a269a632 100644 (file)
@@ -809,6 +809,8 @@ elf_readlink (struct backtrace_state *state, const char *filename,
     }
 }
 
+#define SYSTEM_BUILD_ID_DIR "/usr/lib/debug/.build-id/"
+
 /* Open a separate debug info file, using the build ID to find it.
    Returns an open file descriptor, or -1.
 
@@ -821,7 +823,7 @@ elf_open_debugfile_by_buildid (struct backtrace_state *state,
                               backtrace_error_callback error_callback,
                               void *data)
 {
-  const char * const prefix = "/usr/lib/debug/.build-id/";
+  const char * const prefix = SYSTEM_BUILD_ID_DIR;
   const size_t prefix_len = strlen (prefix);
   const char * const suffix = ".debug";
   const size_t suffix_len = strlen (suffix);
@@ -2813,7 +2815,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
   shstr_size = shstrhdr->sh_size;
   shstr_off = shstrhdr->sh_offset;
 
-  if (!backtrace_get_view (state, descriptor, shstr_off, shstr_size,
+  if (!backtrace_get_view (state, descriptor, shstr_off, shstrhdr->sh_size,
                           error_callback, data, &names_view))
     goto fail;
   names_view_valid = 1;
@@ -2862,7 +2864,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
       /* Read the build ID if present.  This could check for any
         SHT_NOTE section with the right note name and type, but gdb
         looks for a specific section name.  */
-      if (!debuginfo
+      if ((!debuginfo || with_buildid_data != NULL)
          && !buildid_view_valid
          && strcmp (name, ".note.gnu.build-id") == 0)
        {
@@ -2936,7 +2938,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
          if (debugaltlink_name_len < shdr->sh_size)
            {
              /* Include terminating zero.  */
-             debugaltlink_name_len =+ 1;
+             debugaltlink_name_len += 1;
 
              debugaltlink_buildid_data
                = debugaltlink_data + debugaltlink_name_len;
@@ -3041,7 +3043,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
          if (debugaltlink_view_valid)
            backtrace_release_view (state, &debugaltlink_view, error_callback,
                                    data);
-         ret = elf_add (state, NULL, d, base_address, error_callback, data,
+         ret = elf_add (state, "", d, base_address, error_callback, data,
                         fileline_fn, found_sym, found_dwarf, NULL, 0, 1, NULL,
                         0);
          if (ret < 0)
@@ -3080,7 +3082,7 @@ elf_add (struct backtrace_state *state, const char *filename, int descriptor,
          if (debugaltlink_view_valid)
            backtrace_release_view (state, &debugaltlink_view, error_callback,
                                    data);
-         ret = elf_add (state, NULL, d, base_address, error_callback, data,
+         ret = elf_add (state, "", d, base_address, error_callback, data,
                         fileline_fn, found_sym, found_dwarf, NULL, 0, 1, NULL,
                         0);
          if (ret < 0)