Commit Graph

10 Commits

Author SHA1 Message Date
Rafael Espindola b691ccf0a5 Revert "Add terminator to .eh_frame sections"
This reverts commit r296378.

I am pretty sure this is incorrect. In particular, for just

        .cfi_startproc
        nop
        .cfi_endproc

We now add an extra 4 zeros that neither bfd nor gold add.

llvm-svn: 296503
2017-02-28 18:55:08 +00:00
Rui Ueyama 1720ef1343 Add terminator to .eh_frame sections
Patch by Mark Kettenis.

Currenlty ld.lld does not add a terminator (a CIE with its length field
set to zero) to the .eh_frame sections it generates.  While the relevant
standards (the AMD64 SysV ABI and the Linux LSB) are not explicit about
this, such a terminator is expected by some unwinder implementations and
seems to be always emitted by ld.bfd. In addition to that, the Linux LSB

  https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html#EHFRAME

explicitly says that

  The .eh_frame section shall contain 1 or more Call Frame Information
  (CFI) records.

Currently, if the .eh_frame sections of the input files only contain
terminators, ld.lld emits a zero=sized .eh_frame section
which clearly doesn't meet that requirement.

The diff makes sure a terminator gets added to each .eh_frame section
and adjusts all the relevant tests to account for that.  An additional
test isn't needed as these adjustments mean that the existence of the
terminator is tested for by several tests already.

Differential Revision: https://reviews.llvm.org/D30335

llvm-svn: 296378
2017-02-27 20:44:59 +00:00
George Rimar 3fb5a6dc9e [ELF] - Add support of proccessing of the rest allocatable synthetic sections from linkerscript.
This change continues what was started by D27040
Now all allocatable synthetics should be available from script side.

Differential revision: https://reviews.llvm.org/D27131

llvm-svn: 288150
2016-11-29 16:05:27 +00:00
Ed Maste 8fd0196c6f lld: Default image base address to 0x200000 on x86-64
Align to the large page size (known as a superpage or huge page).
FreeBSD automatically promotes large, superpage-aligned allocations.

Differential Revision:	https://reviews.llvm.org/D27042

llvm-svn: 287782
2016-11-23 17:44:02 +00:00
Rui Ueyama 3b04d833c4 Set sh_addralign to 1 instead of 0.
ELF spec says that alignment of 0 is equivalent to 1.
Previously, we arbitrary set to 0 or 1, but always setting to 1
makes our program simpler.

llvm-svn: 275374
2016-07-14 05:46:24 +00:00
Rui Ueyama f86cb90a2d Do not propagate section name and attributes to .eh_frame.
.eh_frame is always ".eh_frame" and its attribute is fixed.
No need to copy from inputs to outputs. GNU gold also sets
SHT_PROGBITS.

llvm-svn: 270443
2016-05-23 15:12:41 +00:00
Rui Ueyama 144debcc0f Remove unnecessary trailing semicolons.
Since this semicolon existed in an early test file,
it has spread to many files.

llvm-svn: 267659
2016-04-27 02:58:27 +00:00
George Rimar f6bc65a3b2 Reapply r257753 with fix:
Added check for terminator CIE/FDE which has zero data size.
void EHOutputSection<ELFT>::addSectionAux(
...
 // If CIE/FDE data length is zero then Length is 4, this
 // shall be considered a terminator and processing shall end.
    if (Length == 4)
      break;
...

After this "Bug 25923 - lld/ELF2 linked application crashes if exceptions were used." is fixed for me. Self link of clang also works.

Initial commit message:
[ELF] - implemented --eh-frame-hdr command line option.

--eh-frame-hdr
Request creation of ".eh_frame_hdr" section and ELF "PT_GNU_EH_FRAME" segment header.

Both gold and the GNU linker support an option --eh-frame-hdr which tell them to construct a header for all the .eh_frame sections. This header is placed in a section named .eh_frame_hdr and also in a PT_GNU_EH_FRAME segment. At runtime the unwinder can find all the PT_GNU_EH_FRAME segments by calling dl_iterate_phdr.
This section contains a lookup table for quick binary search of FDEs.
Detailed info can be found here:
http://www.airs.com/blog/archives/462

Differential revision: http://reviews.llvm.org/D15712

llvm-svn: 257889
2016-01-15 13:34:52 +00:00
Rui Ueyama 5f91ace828 Revert r257753: "[ELF] - implemented --eh-frame-hdr command line option."
This reverts commit r257753 because we cannot link Clang with this patch.

llvm-svn: 257797
2016-01-14 20:32:19 +00:00
George Rimar 28f4fbe480 [ELF] - implemented --eh-frame-hdr command line option.
--eh-frame-hdr
Request creation of ".eh_frame_hdr" section and ELF "PT_GNU_EH_FRAME" segment header.

Both gold and the GNU linker support an option --eh-frame-hdr which tell them to construct a header for all the .eh_frame sections. This header is placed in a section named .eh_frame_hdr and also in a PT_GNU_EH_FRAME segment. At runtime the unwinder can find all the PT_GNU_EH_FRAME segments by calling dl_iterate_phdr.
This section contains a lookup table for quick binary search of FDEs.
Detailed info can be found here:
http://www.airs.com/blog/archives/462

Differential revision: http://reviews.llvm.org/D15712

llvm-svn: 257753
2016-01-14 10:30:32 +00:00