[llvm] r206355 - COFF: add support for .file symbols
Timur Iskhodzhanov
timurrrr at google.com
Wed Apr 16 01:23:06 PDT 2014
VS2013 doesn't seem to like that:
lib\MC\WinCOFFObjectWriter.cpp(636) : error C2070: 'unknown': illegal
sizeof operand
lib\MC\WinCOFFObjectWriter.cpp(637) : error C2338: size mismatch for
COFF::AuxiliaryFile::FileName
2014-04-16 8:15 GMT+04:00 Saleem Abdulrasool <compnerd at compnerd.org>:
> Author: compnerd
> Date: Tue Apr 15 23:15:32 2014
> New Revision: 206355
>
> URL: http://llvm.org/viewvc/llvm-project?rev=206355&view=rev
> Log:
> COFF: add support for .file symbols
>
> Add support for emitting .file records. This is mostly a quality of
> implementation change (more complete support for COFF file emission) that was
> noticed while working on COFF file emission for Windows on ARM.
>
> A .file record is emitted as a symbol with storage class FILE (103) and the name
> ".file". A series of auxiliary format 4 records follow which contain the file
> name. The filename is stored as an ANSI string and is padded with NULL if the
> length is not a multiple of COFF::SymbolSize (18).
>
> Added:
> llvm/trunk/test/MC/COFF/file.s
> Modified:
> llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
> llvm/trunk/lib/MC/WinCOFFStreamer.cpp
>
> Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=206355&r1=206354&r2=206355&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
> +++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Tue Apr 15 23:15:32 2014
> @@ -633,6 +633,35 @@ void WinCOFFObjectWriter::ExecutePostLay
> // "Define" each section & symbol. This creates section & symbol
> // entries in the staging area.
>
> + static_assert(sizeof(COFF::AuxiliaryFile::FileName) == COFF::SymbolSize,
> + "size mismatch for COFF::AuxiliaryFile::FileName");
> + for (auto FI = Asm.file_names_begin(), FE = Asm.file_names_end();
> + FI != FE; ++FI) {
> + // round up to calculate the number of auxiliary symbols required
> + unsigned Count = (FI->size() + COFF::SymbolSize) / COFF::SymbolSize;
> +
> + COFFSymbol *file = createSymbol(".file");
> + file->Data.StorageClass = COFF::IMAGE_SYM_CLASS_FILE;
> + file->Aux.resize(Count);
> +
> + unsigned Offset = 0;
> + unsigned Length = FI->size();
> + for (auto & Aux : file->Aux) {
> + Aux.AuxType = ATFile;
> +
> + if (Length > COFF::SymbolSize) {
> + memcpy(Aux.Aux.File.FileName, FI->c_str() + Offset, COFF::SymbolSize);
> + Length = Length - COFF::SymbolSize;
> + } else {
> + memcpy(Aux.Aux.File.FileName, FI->c_str() + Offset, Length);
> + memset(&Aux.Aux.File.FileName[Length], 0, COFF::SymbolSize - Length);
> + Length = 0;
> + }
> +
> + Offset = Offset + COFF::SymbolSize;
> + }
> + }
> +
> for (MCAssembler::const_iterator i = Asm.begin(), e = Asm.end(); i != e; i++)
> DefineSection(*i);
>
>
> Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=206355&r1=206354&r2=206355&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
> +++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Tue Apr 15 23:15:32 2014
> @@ -266,8 +266,7 @@ void WinCOFFStreamer::EmitTBSSSymbol(con
> }
>
> void WinCOFFStreamer::EmitFileDirective(StringRef Filename) {
> - // Ignore for now, linkers don't care, and proper debug
> - // info will be a much large effort.
> + getAssembler().addFileName(Filename);
> }
>
> // TODO: Implement this if you want to emit .comment section in COFF obj files.
>
> Added: llvm/trunk/test/MC/COFF/file.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/file.s?rev=206355&view=auto
> ==============================================================================
> --- llvm/trunk/test/MC/COFF/file.s (added)
> +++ llvm/trunk/test/MC/COFF/file.s Tue Apr 15 23:15:32 2014
> @@ -0,0 +1,17 @@
> +// RUN: llvm-mc -triple i686-windows -filetype obj %s -o - | llvm-objdump -t - \
> +// RUN: | FileCheck %s -check-prefix CHECK-PRINT
> +
> + .file "null-padded.asm"
> +// CHECK-PRINT: .file
> +// CHECK-PRINT-NEXT: AUX null-padded.asm{{$}}
> +
> + .file "eighteen-chars.asm"
> +
> +// CHECK-PRINT: .file
> +// CHECK-PRINT-NEXT: AUX eighteen-chars.asm{{$}}
> +
> + .file "multiple-auxiliary-entries.asm"
> +
> +// CHECK-PRINT: .file
> +// CHECK-PRINT-NEXT: AUX multiple-auxiliary-entries.asm{{$}}
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list