From 82bab64d3c89975cf4b1ed1f3804cfdd809182e4 Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Wed, 26 Jan 2022 09:18:57 -0500 Subject: [PATCH] all: replace objdump tests with readelf Not all versions of binutil's objdump support non-local architectures (see `objdump --arch` for details). Tweak a few unit test scripts to use readelf (which seems to have better arch detection and support) instead. This will fix these tests to properly verify *.OUTPUT.o files for non-local arches. Signed-off-by: Joe Lawrence --- ppc64le/mcount_loc-issue-1102.test | 23 +++++++++-------------- x86_64/mcount_loc-issue-1102.test | 22 ++++++++-------------- x86_64/zero-page-rela-issue-1064.test | 8 ++++---- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/ppc64le/mcount_loc-issue-1102.test b/ppc64le/mcount_loc-issue-1102.test index 082efe1..34dc218 100755 --- a/ppc64le/mcount_loc-issue-1102.test +++ b/ppc64le/mcount_loc-issue-1102.test @@ -1,19 +1,14 @@ #!/bin/bash -# % objdump -j __mcount_loc -Dr mcount_loc-issue-1102.OUTPUT.o +# Verify an __mcount_loc relocation for netlbl_catmap_getlong: # -# mcount_loc-issue-1102.OUTPUT.o: file format elf64-powerpcle +# % readelf --wide --relocs mcount_loc-issue-1102.OUTPUT.o | \ +# awk '/\.rela__mcount_loc/' RS="\n\n" ORS="\n\n" # -# -# Disassembly of section __mcount_loc: -# -# 0000000000000000 <__mcount_loc>: -# ... -# 0: R_PPC64_ADDR64 netlbl_catmap_getlong+0x4 -# - -rela=$(objdump -j __mcount_loc -Dr mcount_loc-issue-1102.OUTPUT.o 2>/dev/null | \ - awk '$2=="R_PPC64_ADDR64" && $3=="netlbl_catmap_getlong+0x4" { print $3 }' 2>/dev/null) +# Relocation section '.rela__mcount_loc' at offset 0x14d0 contains 1 entry: +# Offset Info Type Symbol's Value Symbol's Name + Addend +# 0000000000000000 0000000200000026 R_PPC64_ADDR64 0000000000000000 netlbl_catmap_getlong + 4 -[[ $rela == "netlbl_catmap_getlong+0x4" ]] && exit 0 -exit 1 +readelf --wide --relocs mcount_loc-issue-1102.OUTPUT.o 2>/dev/null | \ + awk '/\.rela__mcount_loc/' RS="\n\n" ORS="\n\n" | \ + grep -q '\.*\ + 4$' diff --git a/x86_64/mcount_loc-issue-1102.test b/x86_64/mcount_loc-issue-1102.test index 1976367..7d64d23 100755 --- a/x86_64/mcount_loc-issue-1102.test +++ b/x86_64/mcount_loc-issue-1102.test @@ -2,19 +2,13 @@ # Verify an __mcount_loc relocation for netlbl_catmap_getlong: # -# % objdump -j __mcount_loc -Dr mcount_loc-issue-1102.OUTPUT.o +# % readelf --wide --relocs mcount_loc-issue-1102.OUTPUT.o | \ +# awk '/\.rela__mcount_loc/' RS="\n\n" ORS="\n\n" # -# mcount_loc-issue-1102.OUTPUT.o: file format elf64-x86-64 -# -# -# Disassembly of section __mcount_loc: -# -# 0000000000000000 <__mcount_loc>: -# ... -# 0: R_X86_64_64 netlbl_catmap_getlong - -rela=$(objdump -j __mcount_loc -Dr mcount_loc-issue-1102.OUTPUT.o 2>/dev/null | \ - awk '$2=="R_X86_64_64" && $3=="netlbl_catmap_getlong" { print $3 }' 2>/dev/null) +# Relocation section '.rela__mcount_loc' at offset 0x840 contains 1 entry: +# Offset Info Type Symbol's Value Symbol's Name + Addend +# 0000000000000000 0000000200000001 R_X86_64_64 0000000000000000 netlbl_catmap_getlong + 0 -[[ $rela == "netlbl_catmap_getlong" ]] && exit 0 -exit 1 +readelf --wide --relocs mcount_loc-issue-1102.OUTPUT.o 2>/dev/null | \ + awk '/\.rela__mcount_loc/' RS="\n\n" ORS="\n\n" | \ + grep -q '\.*\ + 0$' diff --git a/x86_64/zero-page-rela-issue-1064.test b/x86_64/zero-page-rela-issue-1064.test index 2b4096c..81ecf14 100755 --- a/x86_64/zero-page-rela-issue-1064.test +++ b/x86_64/zero-page-rela-issue-1064.test @@ -7,8 +7,8 @@ assert_num_funcs 1 TESTFILE=$(basename "$0") OUTFILE=${TESTFILE%.test}.OUTPUT.o -# If the issue #1064 is fixed, 'objdump -r ' should show -# R_X86_64_64 relocation like 'empty_zero_page+0x80000000'. +# If the issue #1064 is fixed, there should be a +# R_X86_64_64 relocation like 'empty_zero_page + 80000000'. # If the issue is present, there will be something like -# 'empty_zero_page-0x80000000' there instead. -objdump -r ${OUTFILE} | grep -q -E 'R_X86_64_64\s+empty_zero_page\+0x0*80000000' +# 'empty_zero_page - 80000000' there instead. +readelf --wide --relocs zero-page-rela-issue-1064.OUTPUT.o | grep -q -e '\.*\ + 80000000$'