mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 19:30:29 +00:00
Fix Clang/LLD woes!
Several changes to get Clang and LLD working again: - LLD will always place non-allocated sections at LMA(0x0). Flagged the .zip section as 'a' to fix this. - LLD interprets DEFINED(x) in a subtly-different way, where any symbol declaration counts as defining. Changed several default-value definitions that used DEFINED to instead use PROVIDE_HIDDEN. - Due to the same LLD/DEFINED behavior, EfiMain was always getting linked in. Updated to use a separate flagging variable (USE_EFI). - Clang needed a few new flags to match GCC frame/stack behavior.
This commit is contained in:
parent
d6a039821f
commit
32ca4c44b5
5 changed files with 54 additions and 48 deletions
|
@ -498,10 +498,10 @@ HIDDEN(ape_ram_align = PAGESIZE);
|
||||||
HIDDEN(ape_ram_rva = RVA(ape_ram_vaddr));
|
HIDDEN(ape_ram_rva = RVA(ape_ram_vaddr));
|
||||||
|
|
||||||
HIDDEN(ape_stack_offset = ape_ram_offset + ape_ram_filesz);
|
HIDDEN(ape_stack_offset = ape_ram_offset + ape_ram_filesz);
|
||||||
HIDDEN(ape_stack_vaddr = DEFINED(ape_stack_vaddr) ? ape_stack_vaddr : 0x700000000000 - STACKSIZE);
|
PROVIDE_HIDDEN(ape_stack_vaddr = 0x700000000000 - STACKSIZE);
|
||||||
HIDDEN(ape_stack_paddr = ape_ram_paddr + ape_ram_filesz);
|
HIDDEN(ape_stack_paddr = ape_ram_paddr + ape_ram_filesz);
|
||||||
HIDDEN(ape_stack_filesz = 0);
|
HIDDEN(ape_stack_filesz = 0);
|
||||||
HIDDEN(ape_stack_memsz = DEFINED(ape_stack_memsz) ? ape_stack_memsz : STACKSIZE);
|
PROVIDE_HIDDEN(ape_stack_memsz = STACKSIZE);
|
||||||
HIDDEN(ape_stack_align = 16);
|
HIDDEN(ape_stack_align = 16);
|
||||||
|
|
||||||
HIDDEN(ape_note_offset = ape_rom_offset + (ape_note - ape_rom_vaddr));
|
HIDDEN(ape_note_offset = ape_rom_offset + (ape_note - ape_rom_vaddr));
|
||||||
|
@ -543,7 +543,7 @@ SHSTUB2(ape_macho_dd_count, (ape_macho_end - ape_macho) / 8);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SupportsWindows() || SupportsMetal()
|
#if SupportsWindows() || SupportsMetal()
|
||||||
#define LINK_WINDOWS (SupportsWindows() && !DEFINED(EfiMain))
|
#define LINK_WINDOWS (SupportsWindows() && !DEFINED(USE_EFI))
|
||||||
PFSTUB4(ape_pe_offset, ape_pe - ape_mz);
|
PFSTUB4(ape_pe_offset, ape_pe - ape_mz);
|
||||||
HIDDEN(ape_pe_optsz = ape_pe_sections - (ape_pe + 24));
|
HIDDEN(ape_pe_optsz = ape_pe_sections - (ape_pe + 24));
|
||||||
HIDDEN(ape_pe_shnum = (ape_pe_sections_end - ape_pe_sections) / 40);
|
HIDDEN(ape_pe_shnum = (ape_pe_sections_end - ape_pe_sections) / 40);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include "libc/zip.h"
|
#include "libc/zip.h"
|
||||||
|
|
||||||
// ZIP Central Directory.
|
// ZIP Central Directory.
|
||||||
.section .zip.3,"",@progbits
|
.section .zip.3,"a",@progbits
|
||||||
.hidden __zip_start
|
.hidden __zip_start
|
||||||
.globl __zip_start
|
.globl __zip_start
|
||||||
.type __zip_start,@object
|
.type __zip_start,@object
|
||||||
|
@ -30,7 +30,7 @@ __zip_start:
|
||||||
...
|
...
|
||||||
decentralized content
|
decentralized content
|
||||||
...
|
...
|
||||||
*/.section .zip.5,"",@progbits
|
*/.section .zip.5,"a",@progbits
|
||||||
__zip_end:
|
__zip_end:
|
||||||
.long kZipCdirHdrMagic # magic
|
.long kZipCdirHdrMagic # magic
|
||||||
.short 0 # disk
|
.short 0 # disk
|
||||||
|
|
|
@ -45,7 +45,7 @@ static const EFI_GUID kEfiLoadedImageProtocol = LOADED_IMAGE_PROTOCOL;
|
||||||
* So if you want to trade away Windows so that you can use
|
* So if you want to trade away Windows so that you can use
|
||||||
* UEFI instead of the normal BIOS boot process, do this:
|
* UEFI instead of the normal BIOS boot process, do this:
|
||||||
*
|
*
|
||||||
* STATIC_YOINK("EfiMain");
|
* STATIC_YOINK("USE_EFI");
|
||||||
* int main() { ... }
|
* int main() { ... }
|
||||||
*
|
*
|
||||||
* You can use QEMU to test this, but please note that UEFI
|
* You can use QEMU to test this, but please note that UEFI
|
||||||
|
|
|
@ -4,24 +4,27 @@
|
||||||
|
|
||||||
# TODO: someone who uses clang please mantain this
|
# TODO: someone who uses clang please mantain this
|
||||||
|
|
||||||
# if CLANG=$(command -v clang); then
|
if CLANG=$(command -v clang); then
|
||||||
# mkdir -p o/$MODE/test/libc/release
|
mkdir -p o/$MODE/test/libc/release
|
||||||
# $CLANG \
|
$CLANG \
|
||||||
# -o o/$MODE/test/libc/release/smokeclang2.com.dbg \
|
-o o/$MODE/test/libc/release/smoke_clang.com.dbg \
|
||||||
# -Os \
|
-Os \
|
||||||
# -Wall \
|
-Wall \
|
||||||
# -Werror \
|
-Werror \
|
||||||
# -static \
|
-fuse-ld=ld \
|
||||||
# -fno-pie \
|
-static \
|
||||||
# -nostdlib \
|
-fno-pie \
|
||||||
# -nostdinc \
|
-nostdlib \
|
||||||
# -fuse-ld=lld \
|
-nostdinc \
|
||||||
# -mno-red-zone \
|
-fno-omit-frame-pointer \
|
||||||
# -Wl,-T,o/$MODE/ape/ape.lds \
|
-mno-omit-leaf-frame-pointer \
|
||||||
# -include o/cosmopolitan.h \
|
-fno-stack-protector \
|
||||||
# test/libc/release/smoke.c \
|
-mno-red-zone \
|
||||||
# o/$MODE/libc/crt/crt.o \
|
-Wl,-T,o/$MODE/ape/ape.lds \
|
||||||
# o/$MODE/ape/ape.o \
|
-include o/cosmopolitan.h \
|
||||||
# o/$MODE/cosmopolitan.a || exit
|
test/libc/release/smoke.c \
|
||||||
# o/$MODE/test/libc/release/smokeclang2.com.dbg || exit
|
o/$MODE/libc/crt/crt.o \
|
||||||
# fi
|
o/$MODE/ape/ape.o \
|
||||||
|
o/$MODE/cosmopolitan.a || exit
|
||||||
|
o/$MODE/test/libc/release/smoke_clang.com.dbg || exit
|
||||||
|
fi
|
||||||
|
|
|
@ -4,24 +4,27 @@
|
||||||
|
|
||||||
# TODO: someone who uses clang please mantain this
|
# TODO: someone who uses clang please mantain this
|
||||||
|
|
||||||
# if CLANG=$(command -v clang); then
|
if CLANG=$(command -v clang); then
|
||||||
# mkdir -p o/$MODE/test/libc/release
|
mkdir -p o/$MODE/test/libc/release
|
||||||
# $CLANG \
|
$CLANG \
|
||||||
# -o o/$MODE/test/libc/release/smokeclang.com.dbg \
|
-o o/$MODE/test/libc/release/smoke_lld.com.dbg \
|
||||||
# -Os \
|
-Os \
|
||||||
# -Wall \
|
-Wall \
|
||||||
# -Werror \
|
-Werror \
|
||||||
# -static \
|
-fuse-ld=lld \
|
||||||
# -fno-pie \
|
-static \
|
||||||
# -nostdlib \
|
-fno-pie \
|
||||||
# -nostdinc \
|
-nostdlib \
|
||||||
# -fuse-ld=lld \
|
-nostdinc \
|
||||||
# -mno-red-zone \
|
-fno-omit-frame-pointer \
|
||||||
# -Wl,-T,o/$MODE/ape/ape.lds \
|
-mno-omit-leaf-frame-pointer \
|
||||||
# -include o/cosmopolitan.h \
|
-fno-stack-protector \
|
||||||
# test/libc/release/smoke.c \
|
-mno-red-zone \
|
||||||
# o/$MODE/libc/crt/crt.o \
|
-Wl,-T,o/$MODE/ape/ape.lds \
|
||||||
# o/$MODE/ape/ape.o \
|
-include o/cosmopolitan.h \
|
||||||
# o/$MODE/cosmopolitan.a || exit
|
test/libc/release/smoke.c \
|
||||||
# o/$MODE/test/libc/release/smokeclang.com.dbg || exit
|
o/$MODE/libc/crt/crt.o \
|
||||||
# fi
|
o/$MODE/ape/ape.o \
|
||||||
|
o/$MODE/cosmopolitan.a || exit
|
||||||
|
o/$MODE/test/libc/release/smoke_lld.com.dbg || exit
|
||||||
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue