[llvm-bugs] [Bug 39634] New: Linker doesn't find _GLOBAL_OFFSET_TABLE_

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 12 02:44:51 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39634

            Bug ID: 39634
           Summary: Linker doesn't find _GLOBAL_OFFSET_TABLE_
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: ck at remobjects.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

this bitcode:

------------------------------------------------
; ModuleID = 'prfail.bc'
source_filename = "prfail.c"
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7-unknown-linux-gnueabihf"
@llvm.used = appending global [3 x i8*] [
     i8* bitcast (void()* @__elements_entry_point_helper to i8*),
    i8* bitcast (void()* @__elements_init to i8*),
i8* bitcast (void()* @__elements_fini to i8*)

  ], section "llvm.metadata"


; Function Attrs: noinline nounwind optnone
define dso_local void @_start() #0 {
  call void asm sideeffect ".l4a:\0Aldr     r0, .l1\0Aldr     r0, [r0,
r4]\0Aldr     r3, .l2\0Aldr     r3, [r3, r4]\0Aldr     r12, .l3\0Aldr     r12,
[r12, r4]\0A.l1:\0A   .long __elements_entry_point_helper(GOT)\0A.l2:\0A  
.long __elements_init(GOT)\0A.l3:\0A   .long __elements_fini(GOT)\0A.l4:\0A  
.long   _GLOBAL_OFFSET_TABLE_-(.l4a+8)\0A", ""()
  ret void
}

define void @__elements_entry_point_helper() #0 {
  ret void
}

define void @__elements_init() #0 {
  ret void
}

define void @__elements_fini() #0 {
  ret void
}

attributes #0 = { noinline nounwind optnone }
------------------------------------------------




error:
lld: error: undefined symbol: _GLOBAL_OFFSET_TABLE_
>>> referenced by prfail.c
>>>               lto.tmp:(_start)


this fails:
opt prfail.ll  -O2 -o pr.o
lld -flavor gnu "-dynamic-linker" "/lib/ld-linux-armhf.so.3" "-o" "a.out" pr.o

this works:
llc -O2 prfail.ll -filetype=obj -o pr.o
lld -flavor gnu "-dynamic-linker" "/lib/ld-linux-armhf.so.3" "-o" "a.out" pr.o


even though both should act the same (the only real difference is that 1 is
bitcode).


(There's a second issue that if llvm.used isn't there, it fails to find the 3
methods __elements_init,__elements_fini too __elements_entry_point_helper)

-- 
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/20181112/c5cc7481/attachment.html>


More information about the llvm-bugs mailing list