Skip to content

Commit

Permalink
prelink: Fix MIPS section header check
Browse files Browse the repository at this point in the history
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 <[email protected]>
        * 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 <[email protected]>
  • Loading branch information
Mark Hatle committed Oct 29, 2015
1 parent 88c4a1e commit 9f5c82e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2015-10-29 Mark Hatle <[email protected]>
* 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 <[email protected]>
* get.c: Sync rtld/prelink type_class values

Expand Down
8 changes: 5 additions & 3 deletions src/prelink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions src/prelink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f5c82e

Please sign in to comment.