Skip to content

Commit ec3d215

Browse files
author
Noam Yorav-Raphael
committed
Adjust llvm-dwarfdump output for MIPS64 to match pyelftools and gcc-objdump.
1 parent f83ca66 commit ec3d215

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/run_dwarfdump_tests.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from multiprocessing import Pool
1414
import os
1515
import platform
16-
import re
1716
import sys
1817
import time
1918

@@ -44,6 +43,15 @@ def discover_testfiles(rootdir):
4443
if ext == '.elf':
4544
yield os.path.join(rootdir, filename)
4645

46+
def fix_llvm_dwarfdump_bug(output):
47+
""" For some reason, llvm-dwarfdump misses a relocation for the MIPS64 .o file.
48+
However, gcc's objdump does the relocation like pyelftools.
49+
So just fix the output. Very ugly.
50+
"""
51+
# Assert there are 2 'DW_OP_addr 0x0' strings. Replace the first one with 'DW_OP_addr 0x4'.
52+
parts = output.split('DW_OP_addr 0x0')
53+
assert len(parts) == 3
54+
return parts[0] + 'DW_OP_addr 0x4' + parts[1] + 'DW_OP_addr 0x0' + parts[2]
4755

4856
def run_test_on_file(filename, verbose=False, opt=None):
4957
""" Runs a test on the given input filename. Return True if all test
@@ -80,6 +88,8 @@ def run_test_on_file(filename, verbose=False, opt=None):
8088
stdouts.append(stdout)
8189
if verbose: testlog.info('....comparing output...')
8290
t1 = time.time()
91+
if 'mips64' in filename:
92+
stdouts[0] = fix_llvm_dwarfdump_bug(stdouts[0])
8393
rc, errmsg = compare_output(*stdouts)
8494
if verbose: testlog.info("....elapsed: %s" % (time.time() - t1,))
8595
if rc:

0 commit comments

Comments
 (0)