Bug 27115 - FAIL: dwz-0.13/testsuite/dwz.tests/devel-ignore-size.sh
Summary: FAIL: dwz-0.13/testsuite/dwz.tests/devel-ignore-size.sh
Status: RESOLVED FIXED
Alias: None
Product: dwz
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-27 07:36 UTC by Vitaly Chikunov
Modified: 2021-01-09 11:52 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2020-12-28 00:00:00
Project(s) to access:
ssh public key:


Attachments
example of dwz in/out binaries (7.12 KB, application/x-compressed)
2021-01-03 08:50 UTC, Vitaly Chikunov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vitaly Chikunov 2020-12-27 07:36:25 UTC
dwz 0.13 fails devel-ignore-size.sh test.

I try to reproduce test result manually:

builder@i586:~/RPM/BUILD/dwz-0.13$ make min
cc /usr/src/RPM/BUILD/dwz-0.13/testsuite/dwz.tests/min.c /usr/src/RPM/BUILD/dwz-0.13/testsuite/dwz.tests/min-2.c -o min -g
builder@i586:~/RPM/BUILD/dwz-0.13$ cp min 1
builder@i586:~/RPM/BUILD/dwz-0.13$ readelf -wi 1 | grep '(DW_TAG_partial_unit'
builder@i586:~/RPM/BUILD/dwz-0.13$ ./dwz-for-test 1
builder@i586:~/RPM/BUILD/dwz-0.13$ readelf -wi 1 | grep '(DW_TAG_partial_unit'
 <0><b>: Abbrev Number: 44 (DW_TAG_partial_unit)
    <5d>   DW_AT_import      : <0xb>    [Abbrev Number: 44 (DW_TAG_partial_unit)]
    <4aa>   DW_AT_import      : <0xb>   [Abbrev Number: 44 (DW_TAG_partial_unit)]

Test seems to expect all matches by be 0 always.
Comment 1 Vitaly Chikunov 2020-12-28 12:20:19 UTC
To add, this is readelf from binutils 2.35.1.
Comment 2 Mark Wielaard 2020-12-28 14:33:07 UTC
It looks like binutils 2.35.1 readelf helpfully adds the tag (DW_TAG_partial_unit in this case) to the DW_AT_import when reporting the Abbrev Number. Older readelf produced:

<0><b>: Abbrev Number: 17 (DW_TAG_partial_unit)
    <6b>   DW_AT_import      : <0xb>	[Abbrev Number: 17]
    <da>   DW_AT_import      : <0xb>	[Abbrev Number: 17]

So an workaround might be something like:

diff --git a/testsuite/dwz.tests/pr24468.sh b/testsuite/dwz.tests/pr24468.sh
index 4dac9a1..3b1b671 100644
--- a/testsuite/dwz.tests/pr24468.sh
+++ b/testsuite/dwz.tests/pr24468.sh
@@ -7,7 +7,7 @@ dwz -m 3 1 2
 
 readelf -wi 1 > READELF 2>/dev/null
 
-offsets=$(grep '(DW_TAG_partial_unit' READELF \
+offsets=$(grep '(DW_TAG_partial_unit' READELF | grep -v DW_AT_import \
              | awk '{print $1}' \
              | sed 's/.*<//;s/>.*//')
 for off in $offsets; do
Comment 3 Vitaly Chikunov 2021-01-02 13:08:08 UTC
Mark,

Yes, this strips additional DW_AT_import lines, but test still fail.

builder@x86_64:~/RPM/BUILD/dwz-0.13$ \cp min 1
builder@x86_64:~/RPM/BUILD/dwz-0.13$ readelf -wi 1 | grep '(DW_TAG_partial_unit'
builder@x86_64:~/RPM/BUILD/dwz-0.13$ ./dwz-for-test 1
builder@x86_64:~/RPM/BUILD/dwz-0.13$ readelf -wi 1 | grep '(DW_TAG_partial_unit' | grep -v DW_AT_import
 <0><b>: Abbrev Number: 43 (DW_TAG_partial_unit)
builder@x86_64:~/RPM/BUILD/dwz-0.13$ cat /usr/src/RPM/BUILD/dwz-0.13/testsuite/dwz.tests/devel-ignore-size.sh
...
[ $cnt -eq 0 ]
...
builder@x86_64:~/RPM/BUILD/dwz-0.13$ ls -la min 1
-rwxr-xr-x 1 builder builder 26104 Jan  2 12:58 1
-rwxr-xr-x 1 builder builder 26616 Jan  2 12:55 min

I think dwz modifies test binary even though it's expected to not(?).
Comment 4 Vitaly Chikunov 2021-01-02 14:41:42 UTC
After more investigating, I think it maybe related to glibc update from 2.30 to 2.32. (Time correlation w/o proof yet.)
Comment 5 Tom de Vries 2021-01-03 07:46:40 UTC
Can you attach the binary, before and after dwz-ing?
Comment 6 Vitaly Chikunov 2021-01-03 08:50:57 UTC
Created attachment 13088 [details]
example of dwz in/out binaries

Attached archive with `min` is source, `1` is processed.
Comment 7 Tom de Vries 2021-01-04 08:52:46 UTC
(In reply to Vitaly Chikunov from comment #6)
> Created attachment 13088 [details]
> example of dwz in/out binaries
> 
> Attached archive with `min` is source, `1` is processed.

Comparing the size results, that looks sane:
...
$ ../../../measure/diff.sh min 1
.debug_info      red: 19.24%    1986  1604
.debug_abbrev    red: 16.19%    791  663
.debug_str       red: 0%        1726  1726
total            red: 11.33%    4503 3993
...

Looking at the created partial unit, it contains a couple of base types, like "long unsigned int".

Using a grep, we can see that this comes from compilation units abi-note.c and elf-init.c:
...
$ egrep "DW_AT_name.*(long unsigned int|\.)|Compilation" READELF.min | grep -v "long long"
  Compilation Unit @ offset 0x0:
    <20>   DW_AT_name        : ../sysdeps/x86_64/start.S
  Compilation Unit @ offset 0x2e:
    <3f>   DW_AT_name        : abi-note.c
    <63>   DW_AT_name        : long unsigned int
  Compilation Unit @ offset 0x4ff:
    <510>   DW_AT_name        : init.c
  Compilation Unit @ offset 0x53f:
    <553>   DW_AT_name        : ../sysdeps/x86_64/crti.S
  Compilation Unit @ offset 0x561:
    <572>   DW_AT_name        : min.c
  Compilation Unit @ offset 0x5b4:
    <5c5>   DW_AT_name        : min-2.c
  Compilation Unit @ offset 0x607:
    <618>   DW_AT_name        : elf-init.c
    <64f>   DW_AT_name        : long unsigned int
  Compilation Unit @ offset 0x7a0:
    <7b4>   DW_AT_name        : ../sysdeps/x86_64/crtn.S
...

So this all seems ok.

Without reverting to dwarf assembly, it's hard to create an exec with debug info that is guaranteed to not be compressed.

So for now, the easiest fix is to detect this situation, and mark the test unsupported:
...
diff --git a/testsuite/dwz.tests/devel-ignore-size.sh b/testsuite/dwz.tests/devel-ignore-si
ze.sh
index 5134043..78d28a2 100644
--- a/testsuite/dwz.tests/devel-ignore-size.sh
+++ b/testsuite/dwz.tests/devel-ignore-size.sh
@@ -12,7 +12,9 @@ cnt=$(readelf -wi 1 \
            | grep '(DW_TAG_partial_unit' \
            | wc -l)
 
-[ $cnt -eq 0 ]
+if [ $cnt -ne 0 ]; then
+    exit 77
+fi
 
 cp $execs/min 1
 
...
Comment 8 Tom de Vries 2021-01-04 09:09:02 UTC
https://sourceware.org/git/?p=dwz.git;a=commit;h=282322d59df6cbf3b0af572077d93d5b5b882b41 

[testsuite] Detect when devel-ignore-size.sh is unsupported

In PR27115, a failure of devel-ignore-size.sh is reported.

The test-case:
- tries to transform an executable
- checks that it didn't transform
- retries using --devel-ignore-size
- check that it did transform

The reported failure is in the second step.

Fix this by marking the test unsupported if the second step fails.

2021-01-04  Tom de Vries  <tdevries@suse.de>

PR dwz/27115
* testsuite/dwz.tests/devel-ignore-size.sh: If exec is transformed
without --devel-ignore-size, mark unsupported.
Comment 9 Vitaly Chikunov 2021-01-09 11:52:49 UTC
Tom, thanks for solving this!