1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-23 13:02:52 +02:00
llvm-mirror/test/tools/llvm-cvtres/symbols.test
Bob Haarman 719ad0b0c5 Fix buffer overrun in WindowsResourceCOFFWriter::writeSymbolTable()
Summary:
We were using sprintf(..., "$R06X", <some uint32_t>) to create strings
that are expected to be exactly length 8, but this results in longer
strings if the uint32_t is greater than 0xffffff. This change modifies
the behavior as follows:

 - Uses the loop counter instead of the data offset. This gives us
   sequential symbol names, avoiding collisions as much as possible.

 - Masks the value to 0xffffff to avoid generating names longer than 8
   bytes.

 - Uses formatv instead of sprintf.

Fixes PR35581.

Reviewers: ruiu, zturner

Reviewed By: ruiu

Subscribers: hiraditya, llvm-commits

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

llvm-svn: 321030
2017-12-18 22:10:14 +00:00

34 lines
1.1 KiB
Plaintext

// Check COFF emission of cvtres
// The input was generated with the following command, using the original Windows
// rc.exe:
// > rc /fo test_resource.res /nologo test_resource.rc
// The object file we are comparing against was generated with this command using
// the original Windows cvtres.exe.
// > cvtres /machine:X86 /readonly /nologo /out:test_resource.obj.coff \
// test_resource.res
RUN: llvm-cvtres /verbose /out:%t %p/Inputs/test_resource.res
RUN: llvm-readobj -symbols %t | FileCheck %s
CHECK: Name: $R000000
CHECK-NEXT: Value: 0
CHECK-NEXT: Section: .rsrc$02
CHECK: Name: $R000001
CHECK-NEXT: Value: 24
CHECK-NEXT: Section: .rsrc$02
CHECK: Name: $R000002
CHECK-NEXT: Value: 832
CHECK-NEXT: Section: .rsrc$02
CHECK: Name: $R000003
CHECK-NEXT: Value: 1640
CHECK-NEXT: Section: .rsrc$02
CHECK: Name: $R000004
CHECK-NEXT: Value: 1688
CHECK-NEXT: Section: .rsrc$02
CHECK: Name: $R000006
CHECK-NEXT: Value: 1824
CHECK-NEXT: Section: .rsrc$02
CHECK: Name: $R000007
CHECK-NEXT: Value: 1872
CHECK-NEXT: Section: .rsrc$02