[PATCH] D85994: [LLD][PowerPC] Add check in LLD to produce an error for missing TLSGD/TLSLD

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 08:38:15 PDT 2020


sfertile added a comment.

In D85994#2223415 <https://reviews.llvm.org/D85994#2223415>, @stefanp wrote:

> I am unable to use the assembly files. The problem is that `__tls_get_addr` is a special name for the PPC backend and we cannot generate an object file from incorrect assembly. For example:
>
>   $ cat GeneralDynamic.s
>   	.text
>   GeneralDynamic:                         # @GeneralDynamic
>   	addis 3, 2, x at got@tlsgd at ha
>   	addi 3, 3, x at got@tlsgd at l
>   	bl __tls_get_addr()
>   	blr
>
> Produces:
>
>   $ llvm-mc GeneralDynamic.s --filetype=obj -o /dev/null
>   GeneralDynamic.s:5:20: error: unknown token in expression
>           bl __tls_get_addr()
>                             ^
>   GeneralDynamic.s:5:20: error: invalid TLS call expression
>           bl __tls_get_addr()
>                             ^

I //think// that is because the parens trigger extra parsing. If we omit them we should be able to parse the assembly.

    .text
  GeneralDynamic:                         # @GeneralDynamic
    addis 3, 2, x at got@tlsgd at ha
    addi 3, 3, x at got@tlsgd at l
    bl __tls_get_addr
    blr

produces

  Disassembly of section .text:
  
  0000000000000000 <GeneralDynamic>:
     0:   00 00 62 3c     addis   r3,r2,0
                          0: R_PPC64_GOT_TLSGD16_HA       x
     4:   00 00 63 38     addi    r3,r3,0
                          4: R_PPC64_GOT_TLSGD16_LO       x
     8:   01 00 00 48     bl      8 <GeneralDynamic+0x8>
                          8: R_PPC64_REL24        __tls_get_addr
     c:   20 00 80 4e     blr

Does that give you what you need for the test?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85994/new/

https://reviews.llvm.org/D85994



More information about the llvm-commits mailing list