[llvm-bugs] [Bug 41527] New: ld.lld overaligns TLS segment

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 17 08:11:36 PDT 2019


            Bug ID: 41527
           Summary: ld.lld overaligns TLS segment
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: eleviant at accesssoftek.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

Commit r350681 introduced overalignment of TLS segment for Android
compatibility which however breaks normal AArch64/Linux images when
initial-exec TLS model is used. One possible way to implicitly enable such TLS
model is to use -fsanitize=hwaddress.

Steps to reproduce:
1. Create two C source files: main.c and so.c

/* File: so.c */
extern __thread long tlsvar;

void foo() {
  tlsvar = 10;

/* File: main.c */
#include <assert.h>
__thread long tlsvar;
void foo();
int main() {
  assert(tlsvar == 10);
  return 0;

2. Build executable and shared object to run on Linux/AArch64:
clang -target aarch64-pc-linux -fpic -shared -ftls-model=initial-exec -o
libtlsvar.so so.c -fuse-ld=lld

clang -target aarch64-pc-linux -fpie main.c libtlsvar.so -o main -fuse-ld=bfd

3. Run main - assert will fire.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190417/469fb4e3/attachment-0001.html>

More information about the llvm-bugs mailing list