https://sourceware.org/bugzilla/show_bug.cgi?id=34755
Bug ID: 34755
Summary: objdump -r -l prints "(discriminator 0)" and drops
non-zero discriminators
Product: binutils
Version: 2.48 (HEAD)
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: martin.mirchev at u dot nus.edu
Target Milestone: ---
With -r -l, objdump prints the source location of each relocation, but the
discriminator branches in dump_reloc_set() are inverted compared with the
disassembly path in show_line(): a zero discriminator is printed as
"(discriminator 0)" and a non-zero discriminator is omitted.
$ cat d.c
extern int g(int);
int f(int n) { int s = 0; for (int i = 0; i < n; i++) s += g(i); return s; }
$ gcc -O2 -g -c d.c
$ objdump -d -l d.o | grep 'd.c:'
.../d.c:2
.../d.c:2 (discriminator 3)
.../d.c:2
$ objdump -r -l d.o | grep 'd.c:'
.../d.c:2
.../d.c:2 (discriminator 0)
.../d.c:2
.../d.c:2 (discriminator 0)
Suggested fix (swap the branches, as in show_line()):
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -5690,12 +5690,12 @@
|| (discriminator != last_discriminator)))
{
if (discriminator > 0)
- printf ("%s:%u\n", filename == NULL ? "???" :
- sanitize_string (filename), linenumber);
- else
printf ("%s:%u (discriminator %u)\n",
filename == NULL ? "???" : sanitize_string (filename),
linenumber, discriminator);
+ else
+ printf ("%s:%u\n", filename == NULL ? "???" :
+ sanitize_string (filename), linenumber);
last_line = linenumber;
last_discriminator = discriminator;
if (last_filename != NULL)
With the patch, objdump -r -l prints "d.c:2 (discriminator 3)" for the same
object, matching objdump -d -l.
Seen with binutils 2.47; the same code is present on current master.
This issue was found by an LLM-Enhanced Static Analysis Engine and verified
manually.
--
You are receiving this mail because:
You are on the CC list for the bug.