[lld] [ELF][LTO] Add baseline test for invalid relocations against runtime calls (PR #127286)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 15 12:37:33 PST 2025


================
@@ -0,0 +1,125 @@
+; REQUIRES: arm
+;; https://github.com/llvm/llvm-project/issues/127284
+;; Test for LTO optimizing out references to symbols that are pulled in by
+;; compiler-generated libcalls (post LTO).
+;; The problem here is that the call to __aeabi_ldivmod is generated post-LTO,
+;; during ISel, so aeabi_ldivmod.o is only marked as required afterwards but by
+;; that time we have decided that all the callees of __aeabi_ldivmod are not
+;; needed and have been marked as ABS zero symbols.
+; RUN: rm -rf %t && split-file %s %t && cd %t
+; RUN: llvm-as divmoddi4.ll -o divmoddi4.bc
+; RUN: llvm-mc -filetype=obj -triple=armv7-none-unknown-eabi aeabi_ldivmod.s -o aeabi_ldivmod.o
+;; With an explicit __aebi_ldivmod call in the input IR this works as expected:
+; RUN: llvm-as main-explicit.ll -o main-explicit-ldivmod.bc
+; RUN: ld.lld main-explicit-ldivmod.bc --start-lib aeabi_ldivmod.o divmoddi4.bc --end-lib -o test.exe -Bstatic
+; RUN: llvm-objdump -d -r -t test.exe | FileCheck %s --check-prefix=GOOD-DUMP
+; GOOD-DUMP-LABEL: SYMBOL TABLE:
+; GOOD-DUMP: [[#]] g     F .text	[[#]] _start
----------------
MaskRay wrote:

`_start` is not needed and could be annoying if we ever change the symtab order.

https://github.com/llvm/llvm-project/pull/127286


More information about the llvm-commits mailing list