diff options
| author | Andrew Ng <anng.sw@gmail.com> | 2018-07-23 11:29:46 +0000 |
|---|---|---|
| committer | Andrew Ng <anng.sw@gmail.com> | 2018-07-23 11:29:46 +0000 |
| commit | e33d69199027e68916208bcea4924193b7f88d63 (patch) | |
| tree | a2b5a45dd0bf06412a19c79427a75f0e708e46c1 /lld/ELF/SyntheticSections.cpp | |
| parent | fae3f89088b870dec1c39c83634cc27a44822f9a (diff) | |
| download | bcm5719-llvm-e33d69199027e68916208bcea4924193b7f88d63.tar.gz bcm5719-llvm-e33d69199027e68916208bcea4924193b7f88d63.zip | |
[ELF] Fix handling of FDE negative relative PC addr
Signed values for the FDE PC addr were not correctly handled in
readFdeAddr(). If the value is negative and the type of the value is
smaller than 64 bits, the FDE PC addr overflow error would be
incorrectly triggered.
Fixed readFdeAddr() to properly handle signed values by sign extending
where appropriate.
Differential Revision: https://reviews.llvm.org/D49557
llvm-svn: 337683
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
| -rw-r--r-- | lld/ELF/SyntheticSections.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 4bf6de5ba64..cbcf6bf39a1 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -534,9 +534,14 @@ static uint64_t readFdeAddr(uint8_t *Buf, int Size) { switch (Size) { case DW_EH_PE_udata2: return read16(Buf); + case DW_EH_PE_sdata2: + return (int16_t)read16(Buf); case DW_EH_PE_udata4: return read32(Buf); + case DW_EH_PE_sdata4: + return (int32_t)read32(Buf); case DW_EH_PE_udata8: + case DW_EH_PE_sdata8: return read64(Buf); case DW_EH_PE_absptr: return readUint(Buf); @@ -551,7 +556,7 @@ uint64_t EhFrameSection::getFdePc(uint8_t *Buf, size_t FdeOff, // The starting address to which this FDE applies is // stored at FDE + 8 byte. size_t Off = FdeOff + 8; - uint64_t Addr = readFdeAddr(Buf + Off, Enc & 0x7); + uint64_t Addr = readFdeAddr(Buf + Off, Enc & 0xf); if ((Enc & 0x70) == DW_EH_PE_absptr) return Addr; if ((Enc & 0x70) == DW_EH_PE_pcrel) |

