2019-06-10 18:09:36 +08:00
|
|
|
# REQUIRES: x86
|
[COFF] Fix /export:foo=bar when bar is a weak alias
Summary:
When handling exports from the command line or from .def files, the
linker does a "fuzzy" string lookup to allow finding mangled symbols.
However, when the symbol is re-exported under a new name, the linker has
to transfer the decorations from the exported symbol over to the new
name. This is implemented by taking the mangled symbol that was found in
the object and replacing the original symbol name with the export name.
Before this patch, LLD implemented the fuzzy search by adding an
undefined symbol with the unmangled name, and then during symbol
resolution, checking if similar mangled symbols had been added after the
last round of symbol resolution. If so, LLD makes the original symbol a
weak alias of the mangled symbol. Later, to get the original symbol
name, LLD would look through the weak alias and forward it on to the
import library writer, which copies the symbol decorations. This
approach doesn't work when bar is itself a weak alias, as is the case in
asan. It's especially bad when the aliasee of bar contains the string
"bar", consider "bar_default". In this case, we would end up exporting
the symbol "foo_default" when we should've exported just "foo".
To fix this, don't look through weak aliases to find the mangled name.
Save the mangled name earlier during fuzzy symbol lookup.
Fixes PR42074
Reviewers: mstorsjo, ruiu
Subscribers: thakis, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62984
llvm-svn: 362849
2019-06-08 06:05:12 +08:00
|
|
|
# RUN: llvm-mc -triple i686-windows-msvc %s -o %t.obj -filetype=obj
|
[COFF] Implement /safeseh:no and check @feat.00 flags by default
Summary:
Fixes PR41828. Before this, LLD always emitted SafeSEH chunks and
defined __safe_se_handler_table & size. Now, /safeseh:no leaves those
undefined.
Additionally, we were checking for the safeseh @feat.00 flag in two
places: once to emit errors, and once during safeseh table construction.
The error was set up to be off by default, but safeseh is supposed to be
on by default. I combined the two checks, so now LLD emits an error if
an input object lacks @feat.00 and safeseh is enabled. This caused the
majority of 32-bit LLD tests to fail, since many test input object files
lack @feat.00 symbols. I explicitly added -safeseh:no to those tests to
preserve behavior.
Finally, LLD no longer sets IMAGE_DLL_CHARACTERISTICS_NO_SEH if any
input file wasn't compiled for safeseh.
Reviewers: mstorsjo, ruiu, thakis
Reviewed By: ruiu, thakis
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63570
llvm-svn: 366238
2019-07-17 02:17:33 +08:00
|
|
|
# RUN: lld-link -safeseh:no %t.obj -out:%t.dll -dll -nodefaultlib -noentry -export:foo_std=bar_std -export:foo_fast=bar_fast
|
[COFF] Fix /export:foo=bar when bar is a weak alias
Summary:
When handling exports from the command line or from .def files, the
linker does a "fuzzy" string lookup to allow finding mangled symbols.
However, when the symbol is re-exported under a new name, the linker has
to transfer the decorations from the exported symbol over to the new
name. This is implemented by taking the mangled symbol that was found in
the object and replacing the original symbol name with the export name.
Before this patch, LLD implemented the fuzzy search by adding an
undefined symbol with the unmangled name, and then during symbol
resolution, checking if similar mangled symbols had been added after the
last round of symbol resolution. If so, LLD makes the original symbol a
weak alias of the mangled symbol. Later, to get the original symbol
name, LLD would look through the weak alias and forward it on to the
import library writer, which copies the symbol decorations. This
approach doesn't work when bar is itself a weak alias, as is the case in
asan. It's especially bad when the aliasee of bar contains the string
"bar", consider "bar_default". In this case, we would end up exporting
the symbol "foo_default" when we should've exported just "foo".
To fix this, don't look through weak aliases to find the mangled name.
Save the mangled name earlier during fuzzy symbol lookup.
Fixes PR42074
Reviewers: mstorsjo, ruiu
Subscribers: thakis, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62984
llvm-svn: 362849
2019-06-08 06:05:12 +08:00
|
|
|
# RUN: llvm-nm %t.lib | FileCheck %s
|
|
|
|
|
|
|
|
# MSVC fudges the lookup of 'bar' to allow it to find the stdcall function
|
|
|
|
# _bar_std@8, and then exports _foo_std@8. Same for fastcall and other mangling
|
|
|
|
# schemes.
|
|
|
|
|
|
|
|
# CHECK: export-stdcall.s.tmp.dll:
|
|
|
|
# CHECK: 00000000 T @foo_fast@8
|
|
|
|
# CHECK: 00000000 T __imp_@foo_fast@8
|
|
|
|
|
|
|
|
# CHECK: export-stdcall.s.tmp.dll:
|
|
|
|
# CHECK: 00000000 T __imp__foo_std@8
|
|
|
|
# CHECK: 00000000 T _foo_std@8
|
|
|
|
|
|
|
|
.text
|
|
|
|
.def _bar_std@8; .scl 2; .type 32; .endef
|
|
|
|
.globl _bar_std@8
|
|
|
|
_bar_std@8:
|
|
|
|
movl 8(%esp), %eax
|
|
|
|
movl 4(%esp), %ecx
|
|
|
|
leal 42(%ecx,%eax), %eax
|
|
|
|
retl $8
|
|
|
|
|
|
|
|
.def @bar_fast@8; .scl 2; .type 32; .endef
|
|
|
|
.globl @bar_fast@8
|
|
|
|
@bar_fast@8:
|
|
|
|
leal 42(%ecx,%eax), %eax
|
|
|
|
retl
|
|
|
|
|