<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Linker doesn't find _GLOBAL_OFFSET_TABLE_"
   href="https://bugs.llvm.org/show_bug.cgi?id=39634">39634</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Linker doesn't find _GLOBAL_OFFSET_TABLE_
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lld
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>ELF
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ck@remobjects.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, peter.smith@linaro.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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_
<span class="quote">>>> referenced by prfail.c
>>>               lto.tmp:(_start)</span >


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)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>