[PATCH] D109400: [LLD] Add archive Name to relocaiton overflow printout
Alexander Yermolovich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 22 17:32:02 PDT 2021
ayermolo updated this revision to Diff 381687.
ayermolo added a comment.
Added test.
Was waiting to make sure patch is in right direction before spending time on a test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109400/new/
https://reviews.llvm.org/D109400
Files:
lld/ELF/InputSection.cpp
lld/test/ELF/Inputs/debug-reloc-overflow-error-helper.s
lld/test/ELF/debug-reloc-overflow-error.s
Index: lld/test/ELF/debug-reloc-overflow-error.s
===================================================================
--- /dev/null
+++ lld/test/ELF/debug-reloc-overflow-error.s
@@ -0,0 +1,34 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/debug-reloc-overflow-error-helper.s -o %t1.o
+# RUN: llvm-ar rc %t1.a %t1.o
+# RUN: not ld.lld %t.o %t1.a -o /dev/null 2>&1 | FileCheck %s
+
+## Check that archive name is printed out.
+# CHECK: {{.*}}.a(helper.cpp):(.debug_info+0xC): relocation R_X86_64_32 out of range: 18446462598732840960 is not in [0, 4294967295]; consider recompiling with -fdebug-types-section to reduce size of debug sections
+
+ .text
+ .file "main.cpp"
+ .globl main # -- Begin function main
+ .p2align 4, 0x90
+ .type main, at function
+main: # @main
+ .cfi_startproc
+# %bb.0: # %entry
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ movl $0, -4(%rbp)
+ movl counter2, %eax
+ popq %rbp
+ .cfi_def_cfa %rsp, 8
+ retq
+.Lfunc_end0:
+ .size main, .Lfunc_end0-main
+ .cfi_endproc
+ # -- End function
+ .section ".note.GNU-stack","", at progbits
+ .addrsig
+ .addrsig_sym counter2
Index: lld/test/ELF/Inputs/debug-reloc-overflow-error-helper.s
===================================================================
--- /dev/null
+++ lld/test/ELF/Inputs/debug-reloc-overflow-error-helper.s
@@ -0,0 +1,37 @@
+ .text
+ .file "helper.cpp"
+ .file 1 "" "helper.cpp"
+ .type counter2, at object # @counter2
+ .bss
+ .globl counter2
+ .p2align 2
+counter2:
+ .long 0 # 0x0
+ .size counter2, 4
+
+ .section .debug_abbrev,"", at progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 3 # DW_AT_name
+ .byte 0 # DW_CHILDREN_no
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_info,"", at progbits
+.Lcu_begin0:
+ .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
+.Ldebug_info_start0:
+ .short 4 # DWARF version number
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x30 DW_TAG_compile_unit
+ .long .Linfo_string0 - 0x1000000000000 # DW_AT_name
+ .byte 0 # End Of Children Mark
+.Ldebug_info_end0:
+ .section .debug_str,"MS", at progbits,1
+.Linfo_string0:
+ .asciz "s" # string offset=0
+ .section ".note.GNU-stack","", at progbits
+ .addrsig
+ .section .debug_line,"", at progbits
+.Lline_table_start0:
Index: lld/ELF/InputSection.cpp
===================================================================
--- lld/ELF/InputSection.cpp
+++ lld/ELF/InputSection.cpp
@@ -306,6 +306,8 @@
std::string srcFile = std::string(getFile<ELFT>()->sourceFile);
if (srcFile.empty())
srcFile = toString(file);
+ else if (!file->archiveName.empty())
+ srcFile = file->archiveName + "(" + srcFile + ")";
if (Defined *d = getEnclosingFunction<ELFT>(offset))
return srcFile + ":(function " + toString(*d) + ": " + secAndOffset + ")";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109400.381687.patch
Type: text/x-patch
Size: 3571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211023/501cf77b/attachment.bin>
More information about the llvm-commits
mailing list