Bug 22969 - Add support for R_AARCH64_TLSLE_LDST8_TPREL_LO12 relocation.
Summary: Add support for R_AARCH64_TLSLE_LDST8_TPREL_LO12 relocation.
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-14 14:17 UTC by Peter Smith
Modified: 2018-03-31 12:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch to add support for new TLSLE relocs (1.08 KB, patch)
2018-03-28 01:28 UTC, Cary Coutant
Details | Diff
Updated patch to add support for new TLSLE relocs (1.24 KB, patch)
2018-03-28 01:57 UTC, Cary Coutant
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Smith 2018-03-14 14:17:20 UTC
In a recent change to LLVM (https://reviews.llvm.org/D44355) an attempt was made to fold the add and the ldr in the sequence:

mrs x1, TPIDR_EL0
add x2, x1, :tprel_hi12:local_exec_var
add x3, x2, :tprel_lo12_nc:local_exec_var
ldr w0, [x3]

to:

mrs x1, TPIDR_EL0
add x2, x1, :tprel_hi12:local_exec_var
ldr w0, [x2, :tprel_lo12_nc:local_exec_var]

Unfortunately for this to work support is needed for the R_AARCH_TLSLE_LDST8_TPREL_LO12 relocation that 
ldr w0, [x2, :tprel_lo12_nc:local_exec_var] uses.

It looks like only R_AARCH64_TLSLE_ADD_TPREL_LO12 is supported in binutils trunk (gold and bfd right now). It would be nice to add support for that relocation to enable the relaxation.
Comment 1 Cary Coutant 2018-03-28 01:28:05 UTC
Created attachment 10918 [details]
Patch to add support for new TLSLE relocs
Comment 2 Cary Coutant 2018-03-28 01:57:33 UTC
Created attachment 10919 [details]
Updated patch to add support for new TLSLE relocs
Comment 3 cvs-commit@gcc.gnu.org 2018-03-28 16:11:36 UTC
The master branch has been updated by Cary Coutant <ccoutant@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e82e6b2b19eb796fed161b1658de6d5f763c18de

commit e82e6b2b19eb796fed161b1658de6d5f763c18de
Author: Cary Coutant <ccoutant@gmail.com>
Date:   Tue Mar 27 18:24:48 2018 -0700

    Add support for R_AARCH64_TLSLE_LDST8_TPREL_LO12, etc.
    
    elfcpp/
    	PR gold/22969
    	* aarch64.h: Fix spelling of R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC.
    gold/
    	PR gold/22969
    	* aarch64-reloc.def: Add TLSLE_LDST* relocations.
    	* aarch64.cc (Target_aarch64::optimize_tls_reloc): Likewise.
    	(Target_aarch64::Scan::local): Likewise.
    	(Target_aarch64::Scan::global): Likewise.
    	(Target_aarch64::Relocate::relocate): Likewise.
    	(Target_aarch64::Relocate::relocate_tls): Likewise.
Comment 4 Cary Coutant 2018-03-28 16:23:59 UTC
Now supported on trunk.