62 lines
2.4 KiB
Diff
62 lines
2.4 KiB
Diff
diff -up file-4.23/src/readelf.c.ELF file-4.23/src/readelf.c
|
|
--- file-4.23/src/readelf.c.ELF 2007-12-27 17:30:52.000000000 +0100
|
|
+++ file-4.23/src/readelf.c 2008-01-28 13:28:23.000000000 +0100
|
|
@@ -45,7 +45,7 @@ private int dophn_core(struct magic_set
|
|
off_t, int *);
|
|
#endif
|
|
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
|
|
- off_t, int *);
|
|
+ off_t, int *, int);
|
|
private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, int *);
|
|
private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
|
|
int, size_t, int *);
|
|
@@ -795,7 +795,7 @@ doshn(struct magic_set *ms, int class, i
|
|
*/
|
|
private int
|
|
dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
|
|
- int num, size_t size, off_t fsize, int *flags)
|
|
+ int num, size_t size, off_t fsize, int *flags, int sh_num)
|
|
{
|
|
Elf32_Phdr ph32;
|
|
Elf64_Phdr ph64;
|
|
@@ -864,6 +864,19 @@ dophn_exec(struct magic_set *ms, int cla
|
|
return -1;
|
|
align = 4;
|
|
}
|
|
+ /* If we have a section header table, handle note
|
|
+ sections just in doshn. Handling them also here
|
|
+ means that for executables we print the note content
|
|
+ twice and, more importantly, don't handle
|
|
+ strip -o created debuginfo files correctly.
|
|
+ They have PT_NOTE header, but the actual note
|
|
+ content is not present in the debuginfo file,
|
|
+ only in the original stripped executable or library.
|
|
+ The corresponding .note.* section is SHT_NOBITS
|
|
+ rather than SHT_NOTE, so doshn will not look
|
|
+ at it. */
|
|
+ if (sh_num)
|
|
+ break;
|
|
/*
|
|
* This is a PT_NOTE section; loop through all the notes
|
|
* in the section.
|
|
@@ -975,7 +988,8 @@ file_tryelf(struct magic_set *ms, int fd
|
|
fd, (off_t)getu32(swap, elfhdr.e_phoff),
|
|
getu16(swap, elfhdr.e_phnum),
|
|
(size_t)getu16(swap, elfhdr.e_phentsize),
|
|
- fsize, &flags) == -1)
|
|
+ fsize, &flags, getu16(swap, elfhdr.e_shnum))
|
|
+ == -1)
|
|
return -1;
|
|
if (doshn(ms, class, swap, fd,
|
|
(off_t)getu32(swap, elfhdr.e_shoff),
|
|
@@ -1018,7 +1032,8 @@ file_tryelf(struct magic_set *ms, int fd
|
|
(off_t)elf_getu64(swap, elfhdr.e_phoff),
|
|
getu16(swap, elfhdr.e_phnum),
|
|
(size_t)getu16(swap, elfhdr.e_phentsize),
|
|
- fsize, &flags) == -1)
|
|
+ fsize, &flags,
|
|
+ getu16(swap, elfhdr.e_shnum)) == -1)
|
|
return -1;
|
|
}
|
|
if (doshn(ms, class, swap, fd,
|