History

scripts/sortextable: add support for ET_DYN binaries

Add support to scripts/sortextable for handling relocatable (PIE) executables, whose ELF type is ET_DYN, not ET_EXEC. Other than adding support for the new type, no changes are needed.

Ard Biesheuvel committed 10 years ago

Commit 7b957b61 parent 4a2e0341 file · +4 −4Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/sortextable.c+4−4
@@ -266,9 +266,9 @@ do_file(char const *const fname) · 265 unmodified lines
266266 break;
267267 } /* end switch */
268268 if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0
269− || r2(&ehdr->e_type) != ET_EXEC
269+ || (r2(&ehdr->e_type) != ET_EXEC && r2(&ehdr->e_type) != ET_DYN)
270270 || ehdr->e_ident[EI_VERSION] != EV_CURRENT) {
271− fprintf(stderr, "unrecognized ET_EXEC file %s\n", fname);
271+ fprintf(stderr, "unrecognized ET_EXEC/ET_DYN file %s\n", fname);
272272 fail_file();
273273 }
274274
@@ -304,7 +304,7 @@ do_file(char const *const fname) · 29 unmodified lines
304304 if (r2(&ehdr->e_ehsize) != sizeof(Elf32_Ehdr)
305305 || r2(&ehdr->e_shentsize) != sizeof(Elf32_Shdr)) {
306306 fprintf(stderr,
307− "unrecognized ET_EXEC file: %s\n", fname);
307+ "unrecognized ET_EXEC/ET_DYN file: %s\n", fname);
308308 fail_file();
309309 }
310310 do32(ehdr, fname, custom_sort);
@@ -314,7 +314,7 @@ do_file(char const *const fname) · 3 unmodified lines
314314 if (r2(&ghdr->e_ehsize) != sizeof(Elf64_Ehdr)
315315 || r2(&ghdr->e_shentsize) != sizeof(Elf64_Shdr)) {
316316 fprintf(stderr,
317− "unrecognized ET_EXEC file: %s\n", fname);
317+ "unrecognized ET_EXEC/ET_DYN file: %s\n", fname);
318318 fail_file();
319319 }
320320 do64(ghdr, fname, custom_sort);