From 9f5c82e299b47014d2b1a970294fcc6acb77d882 Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Thu, 29 Oct 2015 11:01:16 -0500 Subject: [PATCH] prelink: Fix MIPS section header check MIPS has added a new SHT_MIPS_ABIFLAGS section, which the prelinker did not know it could skip. Add this to the list of items to be OK to skip. 2015-10-29 Mark Hatle * prelink.h: Define SHT_MIPS_ABIFLAGS if not set * prelink.c: OK to skip SHT_MIPS_ABIFLAGS optimize the loop to stop on the first bad entry adjust the error to give us more info on the bad section Signed-off-by: Mark Hatle --- ChangeLog | 6 ++++++ src/prelink.c | 8 +++++--- src/prelink.h | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7dfb292..e8e40a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-10-29 Mark Hatle + * prelink.h: Define SHT_MIPS_ABIFLAGS if not set + * prelink.c: OK to skip SHT_MIPS_ABIFLAGS + optimize the loop to stop on the first bad entry + adjust the error to give us more info on the bad section + 2015-10-28 Mark Hatle * get.c: Sync rtld/prelink type_class values diff --git a/src/prelink.c b/src/prelink.c index 0798811..64c4fea 100644 --- a/src/prelink.c +++ b/src/prelink.c @@ -420,7 +420,7 @@ prelink_prepare (DSO *dso) int safe = 1, align = 0, last; GElf_Addr start, adjust, adjust1, adjust2; - for (i = 1; i < (rinfo.plt ? rinfo.plt : rinfo.first); i++) + for (i = 1; (i < (rinfo.plt ? rinfo.plt : rinfo.first)) & safe; i++) switch (dso->shdr[i].sh_type) { case SHT_HASH: @@ -441,6 +441,7 @@ prelink_prepare (DSO *dso) case SHT_DYNAMIC: case SHT_MIPS_REGINFO: case SHT_MIPS_OPTIONS: + case SHT_MIPS_ABIFLAGS: /* The same applies to these sections on MIPS. The convention is to put .dynamic and .reginfo near the beginning of the read-only segment, before the program text. No relocations @@ -456,10 +457,11 @@ prelink_prepare (DSO *dso) if (! safe) { - error (0, 0, "%s: Cannot safely convert %s' section from REL to RELA", + error (0, 0, "%s: Cannot safely convert %s' section from REL to RELA: due to section 0x%x [%u]", dso->filename, strptr (dso, dso->ehdr.e_shstrndx, dso->shdr[rinfo.rel_to_rela - ? rinfo.first : rinfo.plt].sh_name)); + ? rinfo.first : rinfo.plt].sh_name), + dso->shdr[i-1].sh_type, i-1); return 1; } diff --git a/src/prelink.h b/src/prelink.h index 299f1fa..de757df 100644 --- a/src/prelink.h +++ b/src/prelink.h @@ -110,6 +110,10 @@ typedef uint8_t Elf64_Byte; #define SHT_MIPS_DWARF 0x7000001e #endif +#ifndef SHT_MIPS_ABIFLAGS +#define SHT_MIPS_ABIFLAGS 0x7000002a +#endif + #ifndef RSS_UNDEF #define RSS_UNDEF 0 #endif