From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by sourceware.org (Postfix) with ESMTPS id 340A73858032 for ; Sun, 16 Jul 2023 23:08:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 340A73858032 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-262ff3a4659so2749589a91.0 for ; Sun, 16 Jul 2023 16:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689548882; x=1692140882; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=fjXBv9ZgwicI3zIkZHAue8rqXF/OK4N8b43ipcexiZA=; b=BU89PQ91/hivdo2S/xZImn7nQFoQqTHP0z3dt46e6g6gX4Abnagn2sC0G2uFMJPEpw zasPwcuF1iK66uzHOx6rm9MiodMcFWqCDPED0OOgQcmldI7NEOzbIKVuKD0xySKZu7FT vQW4tHJYK/Q4yT4EOzvNWE/V6CdjJfzd97y0ijH5IvKHdzi31Nbj/Vfc56JHwjhJNY/H CaHvHr5DfLIhIXaCFdT360uCrS9G22AS24HBPk5oTfnpDf42hsHFz14RpUMXcKfRzo1L u1DxWCvwLSomUcfZsrCcoPDeJKgPewiAOeTbFVZNcYIRWHsA0qo9zB6MruC3HFmj/8R8 wK7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689548882; x=1692140882; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fjXBv9ZgwicI3zIkZHAue8rqXF/OK4N8b43ipcexiZA=; b=EULm+oda0gQXcKB5f4pARBiBkr5RDwTawUWhLZQJRUV+uA0cPH33co7XYGjOfVmZOH ixbIVXZzq0eRfo0tWC20uH2MWoKbYmrN86ZP+f20nSXYXZGI+48yLPRdBrZrq1vPeDDp SNiYa/fCrS8blbnzesfRJctCcWmnxLwJjrmmhRDWMZ2cKOzkQXPUnL6AZfbRExohkr/7 O4CxoKWkm3daaR2YkwNrErUv5W8SDdfHGOC6Z86Xx+ED0/Gvo1GwbJj2lK3wJSqo+5Wa vIHWOCKjLcptQ7xZYYbN4rn02+FPzupv83YSwHn26kDsYUHq3BQwZtpMqSTDuZ90DBjB ND8w== X-Gm-Message-State: ABy/qLaOtckQU5xMCdsFyjCatchF2xumR2A9pkY+3HsTGTvaor/hDml6 JEE24R0D7mL02Lp1Qc2haZqPd+c3dxs= X-Google-Smtp-Source: APBJJlHXjm+jifTU7uw+SWImReSAMqj3cctTjsbLDN7j1B57dZsE6dHQK3ZUTdupYXLjotvLrl4lHw== X-Received: by 2002:a17:90a:ea05:b0:263:62ae:37aa with SMTP id w5-20020a17090aea0500b0026362ae37aamr10442814pjy.47.1689548882025; Sun, 16 Jul 2023 16:08:02 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id ev11-20020a17090aeacb00b00263a985abc0sm4048124pjb.26.2023.07.16.16.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jul 2023 16:08:01 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 793DB114249E; Mon, 17 Jul 2023 08:37:57 +0930 (ACST) Date: Mon, 17 Jul 2023 08:37:57 +0930 From: Alan Modra To: binutils@sourceware.org Cc: chip.kerchner@ibm.com Subject: PR10957, Missing option to really print section+offset Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3034.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: I agree with rth on this, reporting a reloc section+offset is more useful for anyone willing to dig into exactly why a reloc overflow or similar is happening. Many of the reloc error messages have already been converted from using %C to using %H in ld.bfd, to print section+offset as well as file/line/function. This catches a few remaining, and changes gold to do the same. PR 10957 bfd/ * elf32-sh.c (sh_elf_relocate_section): Use %H in error messages. gold/ * object.cc (Relocate_info::location): Always report section+offset. * testsuite/debug_msg.sh: Adjust to suit. * testsuite/x32_overflow_pc32.sh: Likewise. * testsuite/x86_64_overflow_pc32.sh: Likewise. ld/ * emultempl/pe.em (read_addend): Use %H in error message. * emultempl/pep.em (read_addend): Likewise. * ldcref.c (check_reloc_refs): Likewise. * ldmain.c (warning_find_reloc, undefined_symbol): Likewise. * pe-dll.c (pe_create_import_fixup): Likewise. * testsuite/ld-cris/undef2.d: Adjust expected output to suit. * testsuite/ld-cris/undef3.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-i386/compressed1.d: Likewise. * testsuite/ld-ia64/line.exp: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-x86-64/compressed1.d: Likewise. * testsuite/ld-x86-64/line.exp: Likewise. * testsuite/ld-x86-64/pr27587.err: Likewise. diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 499233d1355..cba3529e2a5 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -5010,14 +5010,14 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, { info->callbacks->einfo /* xgettext:c-format */ - (_("%X%C: relocation to \"%s\" references a different segment\n"), + (_("%X%H: relocation to \"%s\" references a different segment\n"), input_bfd, input_section, rel->r_offset, symname); return false; } else info->callbacks->einfo /* xgettext:c-format */ - (_("%C: warning: relocation to \"%s\" references a different segment\n"), + (_("%H: warning: relocation to \"%s\" references a different segment\n"), input_bfd, input_section, rel->r_offset, symname); } diff --git a/gold/object.cc b/gold/object.cc index ccb74057275..77b2690c381 100644 --- a/gold/object.cc +++ b/gold/object.cc @@ -3358,7 +3358,7 @@ Relocate_info::location(size_t, off_t offset) const if (info.enclosing_symbol_type == elfcpp::STT_FUNC) ret += _("function "); ret += info.enclosing_symbol_name; - return ret; + ret += ":"; } ret += "("; diff --git a/gold/testsuite/debug_msg.sh b/gold/testsuite/debug_msg.sh index b808fb8a6e0..51e8a83e1d4 100755 --- a/gold/testsuite/debug_msg.sh +++ b/gold/testsuite/debug_msg.sh @@ -55,9 +55,9 @@ check_missing() # We don't know how the compiler might order these variables, so we # can't test for the actual offset from .data, hence the regexp. -check debug_msg.err "debug_msg.o:debug_msg.cc:fn_array: error: undefined reference to 'undef_fn1()'" -check debug_msg.err "debug_msg.o:debug_msg.cc:fn_array: error: undefined reference to 'undef_fn2()'" -check debug_msg.err "debug_msg.o:debug_msg.cc:badref1: error: undefined reference to 'undef_int'" +check debug_msg.err "debug_msg.o:debug_msg.cc:fn_array:(.*): error: undefined reference to 'undef_fn1()'" +check debug_msg.err "debug_msg.o:debug_msg.cc:fn_array:(.*): error: undefined reference to 'undef_fn2()'" +check debug_msg.err "debug_msg.o:debug_msg.cc:badref1:(.*): error: undefined reference to 'undef_int'" # These tests check only for the source file's file name (not the complete # path) because use of -fdebug-prefix-map may change the path to the source @@ -93,9 +93,9 @@ check debug_msg.err "odr_violation2.cc:3[0-7]" # Check for the same error messages when using --compressed-debug-sections. if test -r debug_msg_cdebug.err then - check debug_msg_cdebug.err "debug_msg_cdebug.o:debug_msg.cc:fn_array: error: undefined reference to 'undef_fn1()'" - check debug_msg_cdebug.err "debug_msg_cdebug.o:debug_msg.cc:fn_array: error: undefined reference to 'undef_fn2()'" - check debug_msg_cdebug.err "debug_msg_cdebug.o:debug_msg.cc:badref1: error: undefined reference to 'undef_int'" + check debug_msg_cdebug.err "debug_msg_cdebug.o:debug_msg.cc:fn_array:(.*): error: undefined reference to 'undef_fn1()'" + check debug_msg_cdebug.err "debug_msg_cdebug.o:debug_msg.cc:fn_array:(.*): error: undefined reference to 'undef_fn2()'" + check debug_msg_cdebug.err "debug_msg_cdebug.o:debug_msg.cc:badref1:(.*): error: undefined reference to 'undef_int'" check debug_msg_cdebug.err ".*/debug_msg.cc:50: error: undefined reference to 'undef_fn1()'" check debug_msg_cdebug.err ".*/debug_msg.cc:55: error: undefined reference to 'undef_fn2()'" check debug_msg_cdebug.err ".*/debug_msg.cc:4[356]: error: undefined reference to 'undef_fn1()'" diff --git a/gold/testsuite/x32_overflow_pc32.sh b/gold/testsuite/x32_overflow_pc32.sh index d0a4cf0374a..6da575e8f2f 100755 --- a/gold/testsuite/x32_overflow_pc32.sh +++ b/gold/testsuite/x32_overflow_pc32.sh @@ -37,6 +37,6 @@ check() # We don't know how the compiler might order these variables, so we # can't test for the actual offset from .data, hence the regexp. -check x86_64_overflow_pc32.err "function bar: error: relocation overflow" +check x86_64_overflow_pc32.err "function bar:(.*): error: relocation overflow" exit 0 diff --git a/gold/testsuite/x86_64_overflow_pc32.sh b/gold/testsuite/x86_64_overflow_pc32.sh index d0a4cf0374a..6da575e8f2f 100755 --- a/gold/testsuite/x86_64_overflow_pc32.sh +++ b/gold/testsuite/x86_64_overflow_pc32.sh @@ -37,6 +37,6 @@ check() # We don't know how the compiler might order these variables, so we # can't test for the actual offset from .data, hence the regexp. -check x86_64_overflow_pc32.err "function bar: error: relocation overflow" +check x86_64_overflow_pc32.err "function bar:(.*): error: relocation overflow" exit 0 diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 7d956bf555c..cd2abe460b9 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1270,7 +1270,7 @@ read_addend (arelent *rel, asection *s) bfd_vma addend = 0; if (!bfd_get_section_contents (s->owner, s, buf, rel->address, sizeof (buf))) - einfo (_("%P: %C: cannot get section contents - auto-import exception\n"), + einfo (_("%P: %H: cannot get section contents - auto-import exception\n"), s->owner, s, rel->address); else addend = bfd_get_32 (s->owner, buf); diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index 99e71951b8a..28d8c8decb3 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -1269,7 +1269,7 @@ read_addend (arelent *rel, asection *s) break; } if (!ok) - einfo (_("%P: %C: cannot get section contents - auto-import exception\n"), + einfo (_("%P: %H: cannot get section contents - auto-import exception\n"), s->owner, s, rel->address); return addend; } diff --git a/ld/ldcref.c b/ld/ldcref.c index da4a4217c20..cf4eba30bdc 100644 --- a/ld/ldcref.c +++ b/ld/ldcref.c @@ -721,7 +721,7 @@ check_reloc_refs (bfd *abfd, asection *sec, void *iarg) in OUTSECNAME. This reloc is from a section which is mapped into a section from which references to OUTSECNAME are prohibited. We must report an error. */ - einfo (_("%X%P: %C: prohibited cross reference from %s to `%pT' in %s\n"), + einfo (_("%X%P: %H: prohibited cross reference from %s to `%pT' in %s\n"), abfd, sec, q->address, outsecname, bfd_asymbol_name (*q->sym_ptr_ptr), outdefsecname); } diff --git a/ld/ldmain.c b/ld/ldmain.c index 25cc89b72f9..06ac2c64fa8 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -1394,7 +1394,7 @@ warning_find_reloc (bfd *abfd, asection *sec, void *iarg) && strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), info->symbol) == 0) { /* We found a reloc for the symbol we are looking for. */ - einfo ("%P: %C: %s%s\n", abfd, sec, q->address, _("warning: "), + einfo ("%P: %H: %s%s\n", abfd, sec, q->address, _("warning: "), info->warning); info->found = true; break; @@ -1484,10 +1484,10 @@ undefined_symbol (struct bfd_link_info *info, if (error_count < MAX_ERRORS_IN_A_ROW) { if (error) - einfo (_("%X%P: %C: undefined reference to `%pT'\n"), + einfo (_("%X%P: %H: undefined reference to `%pT'\n"), abfd, section, address, name); else - einfo (_("%P: %C: warning: undefined reference to `%pT'\n"), + einfo (_("%P: %H: warning: undefined reference to `%pT'\n"), abfd, section, address, name); } else if (error_count == MAX_ERRORS_IN_A_ROW) diff --git a/ld/pe-dll.c b/ld/pe-dll.c index 371915ac1cb..02e03d16948 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -2911,7 +2911,7 @@ pe_create_import_fixup (arelent *rel, asection *s, bfd_vma addend, char *name, } else if (addend != 0) - einfo (_("%X%P: %C: variable '%pT' can't be auto-imported; please read the documentation for ld's --enable-auto-import for details\n"), + einfo (_("%X%P: %H: variable '%pT' can't be auto-imported; please read the documentation for ld's --enable-auto-import for details\n"), s->owner, s, rel->address, (*rel->sym_ptr_ptr)->name); } diff --git a/ld/testsuite/ld-cris/undef2.d b/ld/testsuite/ld-cris/undef2.d index 46015c00add..cd2c43eee4f 100644 --- a/ld/testsuite/ld-cris/undef2.d +++ b/ld/testsuite/ld-cris/undef2.d @@ -1,6 +1,6 @@ -# source: start1.s -# source: stabs1.s -# target: cris-*-*elf* cris-*-*aout* -# as: --em=crisaout -# ld: -mcrisaout -# error: .o:/blah/foo.c:96: undefined reference to `globsym1'$ +#source: start1.s +#source: stabs1.s +#target: cris-*-*elf* cris-*-*aout* +#as: --em=crisaout +#ld: -mcrisaout +#error: .o:/blah/foo.c:96:\(.*\): undefined reference to `globsym1'$ diff --git a/ld/testsuite/ld-cris/undef3.d b/ld/testsuite/ld-cris/undef3.d index e7bca10caf7..e21456b2bae 100644 --- a/ld/testsuite/ld-cris/undef3.d +++ b/ld/testsuite/ld-cris/undef3.d @@ -3,4 +3,4 @@ #target: cris-*-*elf* cris-*-*aout* #as: --em=criself #ld: -mcriself -#error: .o:/blah/foo.c:96: undefined reference to `globsym1'$ +#error: .o:/blah/foo.c:96:\(.*\): undefined reference to `globsym1'$ diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index 1eef9f45667..cf010e5b0e5 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -554,7 +554,7 @@ set build_tests { "-shared" "-fPIC" {beginwarn.c end.c} {{readelf {-S --wide} libbarw.rd} - {warning "^.*beginwarn.c:7: warning: function foo is deprecated\n?$"}} + {warning {^.*beginwarn.c:7:\(.*\): warning: function foo is deprecated\n?$}}} "libbarw.so" "c"} {"Build hidden libbar.so" "-shared" "-fPIC" @@ -1017,7 +1017,7 @@ set run_tests [list \ [list "Run warn with versioned libfoo.so" \ "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \ {main.c} "warn" "warn.out" \ - "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated\n?$} ] \ + "" "c" {^.*beginwarn.c:7:\(.*\): warning: function foo is deprecated\n?$} ] \ [list "Run protected with versioned libfoo.so" \ "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \ {main.c} "protected" "normal.out" ] \ diff --git a/ld/testsuite/ld-i386/compressed1.d b/ld/testsuite/ld-i386/compressed1.d index e9eeef9ae2a..a4294784daa 100644 --- a/ld/testsuite/ld-i386/compressed1.d +++ b/ld/testsuite/ld-i386/compressed1.d @@ -1,7 +1,7 @@ #name: undefined symbol with compressed debug sections #as: --32 #ld: -e foo -melf_i386 --noinhibit-exec -#warning: .*/compressed1.c:13: undefined reference to .bar. +#warning: .*/compressed1.c:13:\(.*\): undefined reference to .bar. #nm: -n #failif diff --git a/ld/testsuite/ld-ia64/line.exp b/ld/testsuite/ld-ia64/line.exp index d39e3ac249d..1fe32cdab9d 100644 --- a/ld/testsuite/ld-ia64/line.exp +++ b/ld/testsuite/ld-ia64/line.exp @@ -52,6 +52,6 @@ proc checkund { string testname } { } } -set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'" +set ml {undefined.c:9:(*): undefined reference to `*this_function_is_not_defined'} checkund $ml $testline diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 9a11de315b8..6f728d77448 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -304,7 +304,7 @@ set lto_link_elf_tests [list \ {pr12760b.c} {} "libpr12760.a"] \ [list "PR ld/12760" \ "-O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin tmpdir/pr12760a.o -Wl,--start-group tmpdir/libpr12760.a -Wl,--end-group" "" \ - {dummy.c} {{warning "pr12760a.c:6: warning: Bad \\.?bar"}} \ + {dummy.c} {{warning {pr12760a.c:6:\(.*\): warning: Bad \.?bar}}} \ "pr12760.exe" "c"] \ [list "PR ld/12975" \ "-shared -O2 -fPIC -flto -fuse-linker-plugin -nostdlib -Wl,-version-script,pr12975.t" "-O2 -flto" \ diff --git a/ld/testsuite/ld-undefined/undefined.exp b/ld/testsuite/ld-undefined/undefined.exp index 69a8f9bf6a9..05b1131d5b4 100644 --- a/ld/testsuite/ld-undefined/undefined.exp +++ b/ld/testsuite/ld-undefined/undefined.exp @@ -89,7 +89,7 @@ if { ![check_compiler_available] } { #setup_xfail "arm*-*-pe*" } - set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'" + set ml {undefined.c:9:(*): undefined reference to `*this_function_is_not_defined'} # With targets that use elf/dwarf2, such as the arm-elf toolchain, # the code in bfd/elf.c:_bfd_elf_find_nearest_line() is called in # order to locate the file name/line number where the undefined diff --git a/ld/testsuite/ld-x86-64/compressed1.d b/ld/testsuite/ld-x86-64/compressed1.d index f97c9ad7da6..8b92278d7b0 100644 --- a/ld/testsuite/ld-x86-64/compressed1.d +++ b/ld/testsuite/ld-x86-64/compressed1.d @@ -1,7 +1,7 @@ #name: undefined symbol with compressed debug sections #as: --64 #ld: -e foo -melf_x86_64 --noinhibit-exec -#warning: .*/compressed1.c:13: undefined reference to .bar. +#warning: .*/compressed1.c:13:\(.*\): undefined reference to .bar. #nm: -n #failif diff --git a/ld/testsuite/ld-x86-64/line.exp b/ld/testsuite/ld-x86-64/line.exp index f5163998862..af01ea227b7 100644 --- a/ld/testsuite/ld-x86-64/line.exp +++ b/ld/testsuite/ld-x86-64/line.exp @@ -52,6 +52,6 @@ proc checkund { string testname } { } } -set ml "undefined.c:9: undefined reference to `*this_function_is_not_defined'" +set ml {undefined.c:9:(*): undefined reference to `*this_function_is_not_defined'} checkund $ml $testline diff --git a/ld/testsuite/ld-x86-64/pr27587.err b/ld/testsuite/ld-x86-64/pr27587.err index 807750ca9d3..9ccca0aec38 100644 --- a/ld/testsuite/ld-x86-64/pr27587.err +++ b/ld/testsuite/ld-x86-64/pr27587.err @@ -1,3 +1,3 @@ #... -.*pr27587/:4: undefined reference to `stack_size' +.*pr27587/:4:\(.*\): undefined reference to `stack_size' #... -- Alan Modra Australia Development Lab, IBM