[PATCH] D62768: [ELF] Don't create an output section named `/DISCARD/` if it is assigned to the special phdr `NONE`
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 08:01:12 PDT 2019
MaskRay added a subscriber: peter.smith.
MaskRay added a comment.
In D62768#1527184 <https://reviews.llvm.org/D62768#1527184>, @andrewng wrote:
> George's comment reminds me why we didn't take this approach in the first place, as it doesn't work correctly for the following test case:
>
> # REQUIRES: x86
> # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
> # RUN: echo "PHDRS { \
> # RUN: exec PT_LOAD FLAGS(0x4 | 0x1); \
> # RUN: rodata PT_LOAD FLAGS(0x4); \
> # RUN: } \
> # RUN: SECTIONS { \
> # RUN: .text : { *(.text) } :exec \
> # RUN: /DISCARD/ : { *(.discard) } :rodata \
> # RUN: .rodata : { *(.rodata) } \
> # RUN: }" > %t.script
> # RUN: ld.lld -o %t --script %t.script %t.o
> # RUN: llvm-readelf -S -l %t | FileCheck --implicit-check-not=/DISCARD/ %s
>
> ## Check that /DISCARD/ phdr is assigned to subsequent sections.
>
> # CHECK: Section Headers
> # CHECK: .text
> # CHECK-NEXT: .rodata
>
> # CHECK: Segment Sections
> # CHECK-NEXT: .text
> # CHECK-NEXT: .rodata
>
> .section .text,"ax"
> ret
>
> .section .rodata,"a"
> .byte 0
>
> .section .discard,"a"
> .byte 0
>
>
> However, this use case is a very unusual edge case, although bfd does handle it.
If I read correctly, this is to assign `/DISCARD` to the memory region `rodata` and expect `.rodata` to inherit the memory region?
Sorry I didn't follow the discussion in D61186 <https://reviews.llvm.org/D61186> and didn't notice D61251 <https://reviews.llvm.org/D61251>. It seems @grimar and @peter.smith were fine with D61251 <https://reviews.llvm.org/D61251> (this patch is essentially D61251 <https://reviews.llvm.org/D61251>). @andrewng if you are ok with letting this somewhat contrived example fail, we can probably still mark this as resolved (wontfix).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62768/new/
https://reviews.llvm.org/D62768
More information about the llvm-commits
mailing list