llvm-project/lld/test/core/undef-fallback.objtxt
Rui Ueyama 70f11d7589 Fix Weak External symbol handling.
The fallback atom was used only when it's searching for a symbol in a library;
if an undefined symbol was not found in a library, the LLD looked for its
fallback symbol in the library.

Although it worked in most cases, because symbols with fallbacks usually occur
only in OLDNAMES.LIB (a standard library), that behavior was incompatible with
link.exe. This patch fixes the issue so that the semantics is the same as
MSVC's link.exe

The new (and correct, I believe) behavior is this:

 - If there's no definition for an undefined atom, replace the undefined atom
   with its fallback and then proceed (e.g. look in the next file or stop
   linking as usual.)

Weak External symbols are underspecified in the Microsoft PE/COFF spec. However,
as long as I observed the behavior of link.exe, this seems to be what we want
for compatibility.

Differential Revision: http://llvm-reviews.chandlerc.com/D2162

llvm-svn: 195269
2013-11-20 20:51:55 +00:00

38 lines
786 B
Plaintext

# RUN: lld -core %s | FileCheck %s
# Test that fallback atoms can be parsed by YAML reader and processed by the
# core linker.
---
defined-atoms:
- name: def1
scope: global
undefined-atoms:
- name: undef1
fallback:
name: fallback1
- name: undef2
fallback:
name: fallback2
---
defined-atoms:
- name: fallback1
undefined-atoms:
- name: def1
fallback:
name: fallback3
...
# CHECK: defined-atoms:
# CHECK-NEXT: - name: def1
# CHECK-NEXT: scope: global
# CHECK-NEXT: - name: fallback1
# CHECK-NEXT: ref-name: fallback1
# CHECK-NEXT: undefined-atoms:
# CHECK-NEXT: - name: fallback1
# CHECK-NEXT: - name: fallback2
# CHECK-NOT: - name: fallback3