[PATCH] elf: Get the real kept section

Hans-Peter Nilsson hp@axis.com
Wed Dec 2 20:58:56 GMT 2020


> From: Hans-Peter Nilsson <Hans-Peter.Nilsson@axis.com>
> Date: Fri, 27 Nov 2020 16:57:05 +0100

> > From: "H.J. Lu" <hjl.tools@gmail.com>
> > Date: Fri, 27 Nov 2020 15:37:37 +0100
> 
> > Something is odd with binutils you built.
> 
> Hm, I reluctantly have to agree

After having had a closer look, I take that back.  The flaw *is*
with the test-case.  Nothing wrong with my autotester setup;
it's even so good it trips bugs other people don't see. ;)

The difference between pass/fail is in the length of the
source-file-path.  A "grep -C 2 CU: *" in binutils shows:

...
dwarf.c-
dwarf.c-	      if (do_wide || strlen (directory) < 76)
dwarf.c:		printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
dwarf.c-	      else
dwarf.c-		printf ("%s:\n", file_table[0].name);

Please always pass the -W (or --wide) option to readelf in
test-cases.

I'll give you that the dwarf.c code is also a bit flawed in
omitting the "CU:" if "strlen (directory) < 76" and also not
counting the length of the basename of the file, just the length
of the directory path.  Better would have been to sprintf to a
temporary buffer, truncate the path, emitting "...".

Committed as obvious.

ld:
	* testsuite/ld-elf/pr26936.d: Pass -W.

Required for the expected "CU:" to be emitted for long
source-paths.  See binutils/dwarf.c:

 if (do_wide || strlen (directory) < 76)
   printf (_("CU: %s/%s:\n"), directory, file_table[0].name);
 else
   printf ("%s:\n", file_table[0].name);


diff --git a/ld/testsuite/ld-elf/pr26936.d b/ld/testsuite/ld-elf/pr26936.d
index 3c854fa0b5..f2bd0d0c6e 100644
--- a/ld/testsuite/ld-elf/pr26936.d
+++ b/ld/testsuite/ld-elf/pr26936.d
@@ -3,7 +3,7 @@
 #source: pr26936c.s
 #as: --gen-debug
 #ld: -z noseparate-code -Ttext-segment 0x10000 -z max-page-size=0x1000
-#readelf: -wL
+#readelf: -wL -W
 #target: [check_shared_lib_support]
 
 #...

brgds, H-P


More information about the Binutils mailing list