Skip to content

Support more than one RW PT_LOAD (LLD's default layout ) #1

@MaskRay

Description

@MaskRay

LLD enables -z relro by default. Since https://reviews.llvm.org/D58892 , LLD switches to R RX RW(relro) RW(non-relro).

bcov currently crashes when patching an LLD linked executable due to:

     DCHECK(regions[ElfModule::Impl::kDataRegionIdx].size() >
            regions[ElfModule::Impl::kRelRoRegionIdx].size());

A larger issue is that kDataRegionIdx and its friends assume a particular layout of program headers. It'd be nice to not assume a particular layout.

I'd recommend testing the following 4 layouts for good platform portability:

  • -fuse-ld=bfd -z noseparate-code (traditional layout)
  • -fuse-ld=bfd -z separate-code (default on Linux x86 since binutils 2.31 2018-02-27 commit "ld: Add --enable-separate-code" made -z separate-code the default on Linux.")
  • -fuse-ld=lld -z noseparate-code (default since LLD 10.0.0 https://reviews.llvm.org/D67482)
  • -fuse-ld=lld -z separate-code (older LLD layout)

Many binutils packages default to -z relro now. It'd be good to test -z norelro as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions