Skip to content

Commit

Permalink
MC: place .file records into the correct section
Browse files Browse the repository at this point in the history
.file records are supposed to have a section identifier of 65534
(IMAGE_SCN_DEBUG) rather than 0.  This is spelt out clearly within the PE/COFF
specification.  Fix this minor oversight with the implementation for support for
.file records.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207851 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
compnerd committed May 2, 2014
1 parent b202527 commit 735f9ed
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/MC/WinCOFFObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
unsigned Count = (FI->size() + COFF::SymbolSize - 1) / COFF::SymbolSize;

COFFSymbol *file = createSymbol(".file");
file->Data.SectionNumber = COFF::IMAGE_SYM_DEBUG;
file->Data.StorageClass = COFF::IMAGE_SYM_CLASS_FILE;
file->Aux.resize(Count);

Expand Down
30 changes: 30 additions & 0 deletions test/MC/ARM/coff-file.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// RUN: llvm-mc -triple thumbv7-windows -filetype obj %s -o - | llvm-objdump -t - \
// RUN: | FileCheck %s

// RUN: llvm-mc -triple thumbv7-windows -filetype obj %s -o - \
// RUN: | llvm-readobj -symbols | FileCheck %s -check-prefix CHECK-SCN

.file "null-padded.asm"
// CHECK: (nx 1) {{0x[0-9]+}} .file
// CHECK-NEXT: AUX null-padded.asm{{$}}
Expand All @@ -15,3 +18,30 @@
// CHECK: (nx 2) {{0x[0-9]+}} .file
// CHECK-NEXT: AUX multiple-auxiliary-entries.asm{{$}}

// CHECK-SCN: Symbols [
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
// CHECK-SCN: Section: (65534)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: null-padded.asm
// CHECK-SCN: }
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
// CHECK-SCN: Section: (65534)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: eighteen-chars.asm
// CHECK-SCN: }
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
// CHECK-SCN: Section: (65534)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: multiple-auxiliary-entries.asm
// CHECK-SCN: }
// CHECK-SCN: }
// CHECK-SCN: ]

30 changes: 30 additions & 0 deletions test/MC/COFF/file.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// RUN: llvm-mc -triple i686-windows -filetype obj %s -o - | llvm-objdump -t - \
// RUN: | FileCheck %s

// RUN: llvm-mc -triple i686-windows -filetype obj %s -o - \
// RUN: | llvm-readobj -symbols | FileCheck %s -check-prefix CHECK-SCN

.file "null-padded.asm"
// CHECK: (nx 1) {{0x[0-9]+}} .file
// CHECK-NEXT: AUX null-padded.asm{{$}}
Expand All @@ -15,3 +18,30 @@
// CHECK: (nx 2) {{0x[0-9]+}} .file
// CHECK-NEXT: AUX multiple-auxiliary-entries.asm{{$}}

// CHECK-SCN: Symbols [
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
// CHECK-SCN: Section: (65534)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: null-padded.asm
// CHECK-SCN: }
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
// CHECK-SCN: Section: (65534)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: eighteen-chars.asm
// CHECK-SCN: }
// CHECK-SCN: }
// CHECK-SCN: Symbol {
// CHECK-SCN: Name: .file
// CHECK-SCN: Section: (65534)
// CHECK-SCN: StorageClass: File
// CHECK-SCN: AuxFileRecord {
// CHECK-SCN: FileName: multiple-auxiliary-entries.asm
// CHECK-SCN: }
// CHECK-SCN: }
// CHECK-SCN: ]

0 comments on commit 735f9ed

Please sign in to comment.