[ELF] Fix reading of PC values of FDEs
authorSimon Atanasyan <simon@atanasyan.com>
Wed, 2 Mar 2016 05:38:42 +0000 (05:38 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Wed, 2 Mar 2016 05:38:42 +0000 (05:38 +0000)
commitea423e261fb45dfbebb7a1d73570dc60268cc979
tree7aa027216b92284599b382d899bdab3f21216b96
parent61205070c457653961bdd5ce513f31f29a73e068
[ELF] Fix reading of PC values of FDEs

The patch fixes two related problems:
- If CIE augmentation string has 'L' token the CIE contains a byte
  defines LSDA encoding. We should skip this byte in `getFdeEncoding`
  routine. Before this fix we do not skip it and if the next token
  is 'R' treat this byte as FDE encoding.
- FDE encoding format has separate flags e.g. DW_EH_PE_pcrel for
  definition of relative pointers. We should add .eh_frame address to
  the PC value iif the DW_EH_PE_pcrel is specified.

http://www.airs.com/blog/archives/460

There is one more not fixed problem in this code. If PC value is encoded
using signed relative format e.g. DW_EH_PE_sdata4 | DW_EH_PE_pcrel we
should sign extend result of read32 to perform calculation correctly.
I am going to fix that in a separate patch.

Differential Revision: http://reviews.llvm.org/D17733

llvm-svn: 262461
lld/ELF/OutputSections.cpp
lld/test/ELF/eh-frame-hdr-abs-fde.s [new file with mode: 0644]