1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/tools/llvm-objcopy/COFF/bigobj.test
Martin Storsjo 9d872b4a9a [llvm-objcopy] [COFF] Fix handling of aux symbols for big objects
The aux symbols were stored in an opaque std::vector<uint8_t>,
with contents interpreted according to the rest of the symbol.

All aux symbol types but one fit in 18 bytes (sizeof(coff_symbol16)),
and if written to a bigobj, two extra padding bytes are written (as
sizeof(coff_symbol32) is 20). In the storage agnostic intermediate
representation, store the aux symbols as a series of coff_symbol16
sized opaque blobs. (In practice, all such aux symbols only consist
of one aux symbol, so this is more flexible than what reality needs.)

The special case is the file aux symbols, which are written in
potentially more than one aux symbol slot, without any padding,
as one single long string. This can't be stored in the same opaque
vector of fixed sized aux symbol entries. The file aux symbols will
occupy a different number of aux symbol slots depending on the type
of output object file. As nothing in the intermediate process needs
to have accurate raw symbol indices, updating that is moved into the
writer class.

Differential Revision: https://reviews.llvm.org/D57009

llvm-svn: 351947
2019-01-23 11:54:51 +00:00

36 lines
1.8 KiB
Plaintext

RUN: %python %p/../Inputs/ungzip.py %p/Inputs/bigobj.o.gz > %t.in.o
RUN: llvm-objdump -t %t.in.o | FileCheck %s --check-prefixes=SYMBOLS,SYMBOLS-BIG,SYMBOLS-ORIG
# Do a plain copy, to check that section numbers in symbols referring
# to sections outside of the small object format are handled correctly.
RUN: llvm-objcopy -R '.text$4' %t.in.o %t.small.o
RUN: llvm-objdump -t %t.in.o | FileCheck %s --check-prefixes=SYMBOLS,SYMBOLS-BIG,SYMBOLS-ORIG
# Remove a section, making the section count fit into a small object.
RUN: llvm-objcopy -R '.text$4' %t.in.o %t.small.o
RUN: llvm-objdump -t %t.small.o | FileCheck %s --check-prefixes=SYMBOLS,SYMBOLS-SMALL,SYMBOLS-REMOVED-SMALL
# Add a .gnu_debuglink section, forcing the object back to big format.
RUN: llvm-objcopy --add-gnu-debuglink=%t.in.o %t.small.o %t.big.o
llvm-objdump -t %t.big.o | FileCheck %s --check-prefixes=SYMBOLS,SYMBOLS-BIG,SYMBOLS-REMOVED-BIG
# In big object format, the .file symbol occupies one symbol table entry for
# the auxillary data, but needs two entries in the small format, forcing the
# raw symbol indices of later symbols to change.
SYMBOLS: SYMBOL TABLE:
SYMBOLS-NEXT: [ 0]{{.*}} (nx 1) {{.*}} .text
SYMBOLS-NEXT: AUX scnlen
SYMBOLS-SMALL-NEXT: [ 2]{{.*}} (nx 2) {{.*}} .file
SYMBOLS-BIG-NEXT: [ 2]{{.*}} (nx 1) {{.*}} .file
SYMBOLS-NEXT: AUX abcdefghijklmnopqrs
SYMBOLS-SMALL-NEXT: [ 5]{{.*}} (nx 0) {{.*}} foo
SYMBOLS-BIG-NEXT: [ 4]{{.*}} (nx 0) {{.*}} foo
# Check that the section numbers outside of signed 16 bit int range
# are represented properly. After removing one section, the section
# numbers decrease.
SYMBOLS-ORIG: [ 5](sec 65280){{.*}} symbol65280
SYMBOLS-REMOVED-SMALL: [ 6](sec 65279){{.*}} symbol65280
SYMBOLS-REMOVED-BIG: [ 5](sec 65279){{.*}} symbol65280