[PATCH] D29653: [ELF] - Assign proper values for DefinedSynthetic symbols attached to non-allocatable sections.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 08:36:55 PST 2017


George Rimar via Phabricator <reviews at reviews.llvm.org> writes:

> grimar created this revision.
>
> We currently have next issue. In the script from testcase,
> orphans are placed before symbol asignment because of align expression.
>
> Therefore .Sym is attached to non allocatable section. And we calculate it
> value wrong. We subtract Body->Section->Addr, but non-allocatable sections
> should have zero VA in output and therefore result value is wrong,
>
> We have Body->Section->Addr != 0 for them internally because use it for calculation of size.
> Patch fixes calculation of such symbols values.
>
>
> https://reviews.llvm.org/D29653
>
> Files:
>   ELF/LinkerScript.cpp
>   test/ELF/linkerscript/symbols-and-orphans.s
>
>
> Index: test/ELF/linkerscript/symbols-and-orphans.s
> ===================================================================
> --- test/ELF/linkerscript/symbols-and-orphans.s
> +++ test/ELF/linkerscript/symbols-and-orphans.s
> @@ -0,0 +1,16 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
> +
> +# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \
> +# RUN:  .text : { *(.text) }                \
> +# RUN:  . = ALIGN(8);                       \
> +# RUN:  Sym = .; }" > %t.script
> +# RUN: ld.lld -o %t2 --script %t.script %t
> +# RUN: llvm-objdump -section-headers -t %t2 | FileCheck %s
> +
> +# CHECK:      SYMBOL TABLE:
> +# CHECK-NEXT: 0000000000000000 *UND* 00000000
> +# CHECK-NEXT: 0000000000000160 .strtab 00000000 Sym
> +
> +.section .orphan,""
> + .quad 0

The issue is independent of the section being an orphan, no? From the
description we would produce the wrong answer even if the section was
mentioned in the script.

If that is the case, please update the test to use a non orphan section.

Cheers,
Rafael


More information about the llvm-commits mailing list