diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -306,6 +306,8 @@ std::string srcFile = std::string(getFile()->sourceFile); if (srcFile.empty()) srcFile = toString(file); + else if (!file->archiveName.empty()) + srcFile = file->archiveName + "(" + srcFile + ")"; if (Defined *d = getEnclosingFunction(offset)) return srcFile + ":(function " + toString(*d) + ": " + secAndOffset + ")"; diff --git a/lld/test/ELF/Inputs/debug-reloc-overflow-error-helper.s b/lld/test/ELF/Inputs/debug-reloc-overflow-error-helper.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/Inputs/debug-reloc-overflow-error-helper.s @@ -0,0 +1,37 @@ + .text + .file "helper.cpp" + .file 1 "" "helper.cpp" + .type counter2,@object # @counter2 + .bss + .globl counter2 + .p2align 2 +counter2: + .long 0 # 0x0 + .size counter2, 4 + + .section .debug_abbrev,"",@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,"",@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",@progbits,1 +.Linfo_string0: + .asciz "s" # string offset=0 + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/lld/test/ELF/debug-reloc-overflow-error.s b/lld/test/ELF/debug-reloc-overflow-error.s new file mode 100644 --- /dev/null +++ b/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,@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","",@progbits + .addrsig + .addrsig_sym counter2