1# RUN: yaml2obj %S/Inputs/long-section-name.yaml -o %t.obj 2 3## Replace the section name field of the object file with /4\0abcde emulating 4## a section name field not fully null-padded at the end. 5# RUN: %python %s %t.obj 6 7## This should print the LongSectionName section. 8# RUN: llvm-objdump --headers %t.obj | FileCheck %s 9 10# CHECK: LongSectionName 11 12import sys 13 14if len(sys.argv) < 2: 15 print("Use: python3 long-section-name.test <OBJECT_FILE>") 16 exit(1) 17 18pattern = b'/4' 19replacement = b'/4\0abcde' 20 21data = None 22with open(sys.argv[1], "rb") as inp: 23 data = inp.read() 24with open(sys.argv[1], "wb") as outp: 25 pos = data.find(pattern) 26 if pos == -1: 27 sys.exit("Error: Pattern /4 not found in " + sys.argv[1]) 28 outp.write(data[:pos]) 29 outp.write(replacement) 30 outp.write(data[pos + len(replacement):]) 31