https://bugs.llvm.org/show_bug.cgi?id=35478

            Bug ID: 35478
           Summary: Sections with linker-script added contents are treated
                    as zero-size for RELRO processing
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedb...@nondot.org
          Reporter: jh7370.2...@my.bristol.ac.uk
                CC: llvm-bugs@lists.llvm.org

This is a problem with r318924, which I discovered when I was trying to rebase
https://reviews.llvm.org/D38361.

The change added isOutputSectionZeroSize(), which is called during the loop for
assigning segments to relro. By this point, the section Size (both for regular
and synthetic sections) field is not final. They are only final once
assignAddresses() has been called. If a linker script contains a section
assignment with BYTE-style commands, or Dot assignments, such as either of the
two below, it will still be treated as empty, and consequently could end up
being allocated to the relro segment.

Example directives:
.foo : { . += 1; *(.foo) }
.bar : { BYTE(1); *(.bar) }

To reproduce, modify the test in ELF/relro-non-contiguous-zerosize.s such that
the ".zero_size" section in the linker script has one of the above, then
observe that it is still in the RELRO segment in the output.

This does not affect all SyntheticSections, because some do not use Size in
their empty() function, but some do. It does affect all other sections.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to