[PATCH] D34204: [LLD][LinkerScript] Allow non-alloc sections to be assigned to segments.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 30 16:19:49 PDT 2017


Andrew Ng via Phabricator <reviews at reviews.llvm.org> writes:

> Index: test/ELF/linkerscript/non-alloc-segment.s
> ===================================================================
> --- /dev/null
> +++ test/ELF/linkerscript/non-alloc-segment.s
> @@ -0,0 +1,28 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
> +
> +## Test that non-alloc section .foo can be assigned to a segment.
> +# RUN: echo "PHDRS {text PT_LOAD; foo 0x12345678;} \
> +# RUN:       SECTIONS { \
> +# RUN:           .text : {*(.text .text*)} :text \
> +# RUN:           .foo : {*(.foo)} :foo \
> +# RUN:       }" > %t.script
> +# RUN: ld.lld -o %t --script %t.script %t.o
> +# RUN: llvm-readobj -elf-output-style=GNU -s -l %t | FileCheck %s
> +
> +# CHECK: Program Headers:
> +# CHECK-NEXT:  Type
> +# CHECK-NEXT:  LOAD
> +# CHECK-NEXT:  <unknown>: 0x12345678
> +
> +# CHECK:      Section to Segment mapping:
> +# CHECK-NEXT:  Segment Sections...
> +# CHECK-NEXT:   00     .text
> +# CHECK-NEXT:   01     .foo

Since the dependency you have is on p_filesz and p_offset, please check
that explicitly. That way you are not depending on whatever llvm-readobj
does for the "Section to Segment mapping".

Also add a comment about it in the test. Something on the lines of your
last email.

LGTM with that.

Cheers,
Rafael


More information about the llvm-commits mailing list