Репозитории ALT
S: | 0.189.0.46.27a8-alt1 |
5.1: | 0.149-alt0.M51.1 |
4.1: | 0.131-alt1 |
4.0: | 0.126-alt1 |
3.0: | 0.108-alt3 |
+backports: | 0.115-alt0.M30.1 |
Другие репозитории
Upstream: | 0.131 |
Группа :: Разработка/C
Пакет: elfutils
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: elfutils-0.147-alt-findtextrel.patch
Скачать
Скачать
--- elfutils/src/findtextrel.c
+++ elfutils/src/findtextrel.c
@@ -29,7 +29,6 @@
#endif
#include <argp.h>
-#include <assert.h>
#include <errno.h>
#include <error.h>
#include <fcntl.h>
@@ -489,6 +488,22 @@ ptrcompare (const void *p1, const void *p2)
}
+static const char *
+get_idx_str (Elf *elf, Elf_Data *symdata, GElf_Shdr *shdr, GElf_Sym *sym,
+ int idx)
+{
+ if (idx == -1)
+ return NULL;
+
+ sym = gelf_getsym (symdata, idx, sym);
+ if (!sym)
+ return NULL;
+
+ const char *str = elf_strptr (elf, shdr->sh_link, sym->st_name);
+ return (str && *str) ? str : NULL;
+}
+
+
static void
check_rel (size_t nsegments, struct segments segments[nsegments],
GElf_Addr addr, Elf *elf, Elf_Scn *symscn, Dwarf *dw,
@@ -554,15 +569,11 @@ check_rel (size_t nsegments, struct segments segments[nsegments],
}
}
- if (lowidx != -1)
+ const char *lowstr = get_idx_str (elf, symdata, shdr, &sym_mem,
+ lowidx);
+ if (lowstr)
{
- sym = gelf_getsym (symdata, lowidx, &sym_mem);
- assert (sym != NULL);
-
- const char *lowstr = elf_strptr (elf, shdr->sh_link,
- sym->st_name);
-
- if (sym->st_value + sym->st_size > addr)
+ if (sym_mem.st_value + sym_mem.st_size > addr)
{
/* It is this function. */
if (tfind (lowstr, knownsrcs, ptrcompare) == NULL)
@@ -572,31 +583,29 @@ the file containing the function '%s' is not compiled with -fpic/-fPIC\n"),
lowstr);
tsearch (lowstr, knownsrcs, ptrcompare);
}
+ return;
}
- else if (highidx == -1)
+ const char *highstr = get_idx_str (elf, symdata, shdr,
+ &sym_mem, highidx);
+ if (!highstr)
printf (gettext ("\
the file containing the function '%s' might not be compiled with -fpic/-fPIC\n"),
lowstr);
else
{
- sym = gelf_getsym (symdata, highidx, &sym_mem);
- assert (sym != NULL);
-
printf (gettext ("\
either the file containing the function '%s' or the file containing the function '%s' is not compiled with -fpic/-fPIC\n"),
- lowstr, elf_strptr (elf, shdr->sh_link,
- sym->st_name));
+ lowstr, highstr);
}
return;
}
- else if (highidx != -1)
+ const char *highstr = get_idx_str (elf, symdata, shdr,
+ &sym_mem, highidx);
+ if (highstr)
{
- sym = gelf_getsym (symdata, highidx, &sym_mem);
- assert (sym != NULL);
-
printf (gettext ("\
the file containing the function '%s' might not be compiled with -fpic/-fPIC\n"),
- elf_strptr (elf, shdr->sh_link, sym->st_name));
+ highstr);
return;
}
}