mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 03:29:57 +00:00
5f6d527f09
GNU binutils import libraries aren't the same kind of short import libraries as link.exe and LLD produce, but are a plain static library containing .idata section chunks. MSVC link.exe can successfully link to them. In order for imports from GNU import libraries to mix properly with the normal import chunks, the chunks from the existing mechanism needs to be added into named sections like .idata$2. These GNU import libraries consist of one header object, a number of object files, one for each imported function/variable, and one trailer. Within the import libraries, the object files are ordered alphabetically in this order. The chunks stemming from these libraries have to be grouped by what library they originate from and sorted, to make sure the section chunks for headers and trailers for the lists are ordered as intended. This is done on all sections named .idata$*, before adding the synthesized chunks to them. Differential Revision: https://reviews.llvm.org/D38513 llvm-svn: 342777
29 lines
1.2 KiB
ArmAsm
29 lines
1.2 KiB
ArmAsm
# REQUIRES: x86
|
|
#
|
|
# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-head.s -filetype=obj -o %t-dabcdh.o
|
|
# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-func.s -filetype=obj -o %t-dabcds00000.o
|
|
# RUN: llvm-mc -triple=x86_64-windows-gnu %p/Inputs/gnu-implib-tail.s -filetype=obj -o %t-dabcdt.o
|
|
# RUN: rm -f %t-implib.a
|
|
# RUN: llvm-ar rcs %t-implib.a %t-dabcdh.o %t-dabcds00000.o %t-dabcdt.o
|
|
# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj
|
|
# RUN: lld-link -out:%t.exe -entry:main -subsystem:console \
|
|
# RUN: %t.obj %t-implib.a
|
|
# RUN: llvm-objdump -s %t.exe | FileCheck -check-prefix=DATA %s
|
|
|
|
.text
|
|
.global main
|
|
main:
|
|
call func
|
|
ret
|
|
|
|
# Check that the linker inserted the null terminating import descriptor,
|
|
# even if there were no normal import libraries, only gnu ones.
|
|
|
|
# DATA: Contents of section .rdata:
|
|
# First import descriptor
|
|
# DATA: 140002000 28200000 00000000 00000000 53200000
|
|
# Last word from first import descriptor, null terminator descriptor
|
|
# DATA: 140002010 38200000 00000000 00000000 00000000
|
|
# Null terminator descriptor and import lookup table.
|
|
# DATA: 140002020 00000000 00000000 48200000 00000000
|