[lld] r257753 - [ELF] - implemented --eh-frame-hdr command line option.

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 14 08:53:37 PST 2016


Hi George,

On Thu, Jan 14, 2016 at 1:30 PM, George Rimar via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: grimar
> Date: Thu Jan 14 04:30:32 2016
> New Revision: 257753
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257753&view=rev
> Log:
> [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.

[...]

> +template <class ELFT>
> +uint8_t EHOutputSection<ELFT>::getFdeEncoding(ArrayRef<uint8_t> D) {
> +  auto Check = [](bool C) {
> +    if (!C)
> +      error("corrupted or unsupported CIE information");
> +  };
> +
> +  Check(D.size() >= 8);
> +  D = D.slice(8);

crtend.o file has .eh_frame section four byte length filled by zero.
If i do not make a mistake after this commit LLD crashes on this
section with "corrupted or unsupported CIE information" error.

[[
$ /home/simon/work/lld/bld/bin/lld -flavor gnu  --sysroot=/ --build-id
--no-add-needed --eh-frame-hdr -m elf_x86_64 --hash-style=both
-dynamic-linker /lib64/ld-linux-x86-64.so.2
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o
-L/usr/lib/gcc/x86_64-linux-gnu/4.7
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib
-L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. hello.o
-lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o
corrupted or unsupported CIE information
]]

Such section is a special case. Take a look at the following code from
BFD linker ...

elf-eh-frame.c - _bfd_elf_parse_eh_frame
[[
  if (sec->size >= 4
      && bfd_get_32 (abfd, ehbuf) == 0
      && cookie->rel == cookie->relend)
    {
      /* Empty .eh_frame section.  */
      free (ehbuf);
      return;
    }
]]

... and especially from Gold linker

ehframe.cc - Eh_frame::add_ehframe_input_section
[[
  if (contents_len == 0)
    return EH_EMPTY_SECTION;

  // If this is the marker section for the end of the data, then
  // return false to force it to be handled as an ordinary input
  // section.  If we don't do this, we won't correctly handle the case
  // of unrecognized .eh_frame sections.
  if (contents_len == 4
      && elfcpp::Swap<32, big_endian>::readval(pcontents) == 0)
    return EH_END_MARKER_SECTION;
]]

I think we should handle this case the same way.

-- 
Simon Atanasyan


More information about the llvm-commits mailing list