diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2018-08-15 17:58:22 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2018-08-15 17:58:22 +0000 |
commit | 62e4fc48a58a8e1cc85d6059a380012f91da0b9c (patch) | |
tree | dab112168cf86539387ec57565fc92cd332149a6 /llvm/lib/Object/ELF.cpp | |
parent | 39fe4808320be925bf7c7e43443cc0d938786e4a (diff) | |
download | bcm5719-llvm-62e4fc48a58a8e1cc85d6059a380012f91da0b9c.tar.gz bcm5719-llvm-62e4fc48a58a8e1cc85d6059a380012f91da0b9c.zip |
llvm-readobj: Fix addend in relocations for android packed format
If a relocation group doesn't have the RELOCATION_GROUP_HAS_ADDEND_FLAG set, then this implies the group's addend equals zero.
In this case android packed format won't encode an explicit addend delta, instead we need to set Addend, the "previous addend" variable, to zero by ourself.
Patch by Yi-Yo Chiang!
Differential Revision: https://reviews.llvm.org/D50601
llvm-svn: 339799
Diffstat (limited to 'llvm/lib/Object/ELF.cpp')
-rw-r--r-- | llvm/lib/Object/ELF.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp index 2eefb7ef13a..da56d97c4bc 100644 --- a/llvm/lib/Object/ELF.cpp +++ b/llvm/lib/Object/ELF.cpp @@ -393,20 +393,17 @@ ELFFile<ELFT>::android_relas(const Elf_Shdr *Sec) const { if (GroupedByAddend && GroupHasAddend) Addend += ReadSLEB(); + if (!GroupHasAddend) + Addend = 0; + for (uint64_t I = 0; I != NumRelocsInGroup; ++I) { Elf_Rela R; Offset += GroupedByOffsetDelta ? GroupOffsetDelta : ReadSLEB(); R.r_offset = Offset; R.r_info = GroupedByInfo ? GroupRInfo : ReadSLEB(); - - if (GroupHasAddend) { - if (!GroupedByAddend) - Addend += ReadSLEB(); - R.r_addend = Addend; - } else { - R.r_addend = 0; - } - + if (GroupHasAddend && !GroupedByAddend) + Addend += ReadSLEB(); + R.r_addend = Addend; Relocs.push_back(R); if (ErrStr) |