This is an archive of the discontinued LLVM Phabricator instance.

[ms] [llvm-ml] Add support for "alias" directive
ClosedPublic

Authored by epastor on Sep 9 2020, 11:09 AM.

Details

Summary

Support the "alias" directive.

Required support for emitWeakReference in MCWinCOFFStreamer.

Diff Detail

Event Timeline

epastor created this revision.Sep 9 2020, 11:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2020, 11:09 AM
epastor requested review of this revision.Sep 9 2020, 11:09 AM
thakis accepted this revision.Sep 14 2020, 10:21 AM

Maybe have a test covering the parse error case too.

llvm/test/tools/llvm-ml/alias.test
16

What happens if you do alias <t5> = <t3> (ie an alias to an alias)?

This revision is now accepted and ready to land.Sep 14 2020, 10:21 AM
epastor added inline comments.Sep 14 2020, 12:29 PM
llvm/test/tools/llvm-ml/alias.test
16

Interesting. Using ml64.exe and alias <t7> = <t4>, you get an alias to an alias:

008 00000000 SECT1  notype ()    External     | t2
009 00000000 UNDEF  notype       WeakExternal | t4
    Default index        8 Alias record
00B 00000000 UNDEF  notype       WeakExternal | t7
    Default index        9 Alias record

Using llvm-ml, you currently get a second weak default-null reference pointing directly to t2:

[ 3](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 0) 0x00000001 t2
...
[ 7](sec  0)(fl 0x00)(ty   0)(scl  69) (nx 1) 0x00000000 t4
AUX indx 9 srch 3
[ 9](sec  1)(fl 0x00)(ty   0)(scl  69) (nx 0) 0x00000001 .weak.t4.default.t1
...
[17](sec  0)(fl 0x00)(ty   0)(scl  69) (nx 1) 0x00000000 t7
AUX indx 19 srch 3
[19](sec  1)(fl 0x00)(ty   0)(scl  69) (nx 0) 0x00000001 .weak.t7.default.t1

These will both alias back to t2, but it's unclear what the effects of this deviation are. What do the .weak .default symbols actually do? Can we guarantee these are equivalent?

epastor updated this revision to Diff 292309.Sep 16 2020, 12:28 PM

Add testing for parse errors

Also, improve error messages

epastor updated this revision to Diff 294414.Sep 25 2020, 1:18 PM

Rebase on parent

epastor updated this revision to Diff 294415.Sep 25 2020, 1:20 PM

Fix error that discarded sections of alias name input

epastor updated this revision to Diff 294795.Sep 28 2020, 1:18 PM

Rebase, and fix tests after D88305 changed how COFF aliases resolve

epastor marked an inline comment as done.Sep 28 2020, 1:20 PM
epastor added inline comments.
llvm/test/tools/llvm-ml/alias.test
16

D88305 resolved this by letting aliases for external symbols point directly to their targets. I've gone ahead and updated these tests to fix that - and also switched them over to llvm-readobj while I was at it, since it involves significantly less regex-hacking to make them match correctly.

epastor updated this revision to Diff 295008.Sep 29 2020, 8:44 AM

Incorporate D88448 to fix external symbol resolution

epastor updated this revision to Diff 295092.Sep 29 2020, 12:50 PM

Update tests for the new way procedures are handled

epastor updated this revision to Diff 295099.Sep 29 2020, 1:15 PM

Rebase on parent

This revision was landed with ongoing or failed builds.Sep 29 2020, 2:00 PM
This revision was automatically updated to reflect the committed changes.