[LLVMbugs] [Bug 23566] New: need arm llvm -fpie to work without __aeabi_read_tp

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 18 13:58:09 PDT 2015


            Bug ID: 23566
           Summary: need arm llvm -fpie to work without __aeabi_read_tp
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
          Assignee: unassignedbugs at nondot.org
          Reporter: chh at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Current clang generates references to __aeabi_read_tp
for arm target under -fpie.
It generates references to __tls_get_addr under -fPIC,
and no special library reference under -fpie for x86 target.

The reference to __aeabi_read_tp caused link time error
because Android run-time library does not have this function yet.

Gcc for arm target generates references to __emutls_get_address under -fpie or

Is there any clang arm target configuration flag to generate
for -fpie references to __tls_get_addr or __emutls_get_address,
or no external reference at all?
This will allow existing AOSP upstream projects to continue using -fpie,
instead of -fPIC or waiting for an upgrade of AOSP library.

The folloing is a test case reduced from Android Open Source
It shows that reference to __aeabi_read_tp is used only for arm -fpie,
not for -fPIC or x86.

$ cat g.i.c
struct mytimeval {
  int tv_sec;
  int tv_usec;
struct tv_valid {
 struct mytimeval last_tv;
 int last_tv_valid;
extern __thread struct tv_valid static_tv_valid;
void fio_gettime(struct mytimeval *tp)
 struct tv_valid *tv = &static_tv_valid;
 if (tv) {
  if (tv->last_tv_valid)
    tp->tv_sec = tv->last_tv.tv_sec;
  tv->last_tv_valid = 1;

$ clang -fpie g.i.c -c -o /tmp/c.x86.pie.o
$ clang -fPIC g.i.c -c -o /tmp/c.x86.PIC.o
$ clang -target arm-linux-androideabi -fpie g.i.c -c -o /tmp/c.pie.o
$ clang -target arm-linux-androideabi -fPIC g.i.c -c -o /tmp/c.PIC.o

$ nm /tmp/c.x86.pie.o | grep -E 'aeabi_read|tls_'
$ nm /tmp/c.x86.PIC.o | grep -E 'aeabi_read|tls_'
        U __tls_get_addr
$ nm /tmp/c.pie.o | grep -E 'aeabi_read|tls_'
        U __aeabi_read_tp
$ nm /tmp/c.PIC.o | grep -E 'aeabi_read|tls_'
        U __tls_get_addr

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/20150518/5d8fe11b/attachment.html>

More information about the llvm-bugs mailing list