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

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 so.c -fuse-ld=lld

clang -target aarch64-pc-linux -fpie main.c -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.
llvm-bugs mailing list

Reply via email to