diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/strip.c | 23 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 6a702ee1..7b59ed60 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2018-10-02 Andreas Schwab <[email protected]> + + * strip.c (handle_elf): Handle ADD/SUB relocation. + 2018-09-13 Mark Wielaard <[email protected]> * readelf.c (print_shdr): Get number of section with elf_getshdrnum. diff --git a/src/strip.c b/src/strip.c index 4a3db1b5..1f7b3cab 100644 --- a/src/strip.c +++ b/src/strip.c @@ -2030,7 +2030,8 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, return true; /* We only do simple absolute relocations. */ - Elf_Type type = ebl_reloc_simple_type (ebl, rtype); + int addsub = 0; + Elf_Type type = ebl_reloc_simple_type (ebl, rtype, &addsub); if (type == ELF_T_NUM) return false; @@ -2109,6 +2110,17 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, /* For SHT_RELA sections we just take the given addend and add it to the value. */ value += addend; + /* For ADD/SUB relocations we need to fetch the + current section contents. */ + if (addsub != 0) + { + Elf_Data *d = gelf_xlatetom (debugelf, &tmpdata, + &rdata, + ehdr->e_ident[EI_DATA]); + if (d == NULL) + INTERNAL_ERROR (fname); + assert (d == &tmpdata); + } } else { @@ -2125,9 +2137,12 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname, switch (type) { -#define DO_TYPE(NAME, Name) \ - case ELF_T_##NAME: \ - tmpbuf.Name += (GElf_##Name) value; \ +#define DO_TYPE(NAME, Name) \ + case ELF_T_##NAME: \ + if (addsub < 0) \ + tmpbuf.Name -= (GElf_##Name) value; \ + else \ + tmpbuf.Name += (GElf_##Name) value; \ break; TYPES; #undef DO_TYPE |
