This is an archive of the discontinued LLVM Phabricator instance.

[CodeView] Minimal support for S_UNAMESPACE records
ClosedPublic

Authored by aganea on Jul 30 2018, 1:11 PM.

Details

Summary

S_UNAMESPACE records are generated by the MSVC compiler when using namespace... directives are used.

Such as:

// SimpleFunction.cpp
// > cl /c SimpleFunction.cpp /Z7
namespace test { }
using namespace test;
int main(void) {
  return 0;
}

This change inherently fixes some 'ignoring unknown symbol record with kind 0x' when passing lld-link -verbose with MSVC .objs.

Diff Detail

Repository
rL LLVM

Event Timeline

aganea created this revision.Jul 30 2018, 1:11 PM

Don't think I've ever seen S_UNAMESPACE before. Do you know what it is?

Don't think I've ever seen S_UNAMESPACE before. Do you know what it is?

It seems to be related to "using namespace" directives and precompiled headers (/Yc).

Compiling the following as precompiled headers (with cl.exe /Yc):

#include <stdio.h>
#include <Windows.h>

...generates:

C:\Users\aganea\Desktop\LLD verbose>cvdump temp\lib.obj | more
Microsoft (R) Debugging Information Dumper  Version 14.00.23611
Copyright (C) Microsoft Corporation.  All rights reserved.


***** SECTION #2

*** SYMBOLS

(00000C) S_OBJNAME: Signature: 1FD3C851, C:\Users\aganea\Desktop\LLD verbose\temp\lib.obj

(000045) S_COMPILE3:
         Language: C++
         Target processor: x64
         Compiled for edit and continue: no
         Compiled without debugging info: no
         Compiled with LTCG: no
         Compiled with /bzalign: no
         Managed code present: no
         Compiled with /GS: yes
         Compiled with /hotpatch: yes
         Converted by CVTCIL: no
         MSIL module: no
         Compiled with /sdl: no
         Compiled with pgo: no
         .EXP module: no
         Pad bits = 0x0000
         Frontend Version: Major = 19, Minor = 14, Build = 26431, QFE = 0
         Backend Version: Major = 19, Minor = 14, Build = 26431, QFE = 0
         Version string: Microsoft (R) Optimizing Compiler

(000081) S_UNAMESPACE: __vc_attributes
(000095) S_UNAMESPACE: helper_attributes
(0000AB) S_UNAMESPACE: atl
(0000B3) S_UNAMESPACE: std

This will be covered by D45213, but if you prefer I could add a test along with this?

Can you update add a proper class for this symbol? Even though it's very simple, just having that class there serves as useful documentation of its format. The steps would be, roughly:

  1. Update CodeViewSymbols.def and change this from a CV_SYMBOL to a SYMBOL_RECORD.
  2. In SymbolRecord.h, add a class for this (looks like it probably has only 1 field).
  3. Update getSymbolNameOffset function in RecordName.cpp to return the correct offset for this symbol.
  4. Fix up any compiler errors that occur as a result of needing to implement virtual functions on things that were ignoring this record before.

It should be pretty straightforward with just boilerplate changes. But after that I think this will be good to go.

aganea updated this revision to Diff 158348.Jul 31 2018, 11:40 AM
aganea retitled this revision from [LLD] Fix 'ignoring unknown symbol record' message to [CodeView] Minimal support for S_UNAMSPACE records.
aganea edited the summary of this revision. (Show Details)
aganea retitled this revision from [CodeView] Minimal support for S_UNAMSPACE records to [CodeView] Minimal support for S_UNAMESPACE records.
zturner accepted this revision.Jul 31 2018, 11:49 AM

Very nice, thanks!

This revision is now accepted and ready to land.Jul 31 2018, 11:49 AM
This revision was automatically updated to reflect the committed changes.