mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 11:18:30 +00:00
Fix link order in cosmopolitan.a
It turned out that the linker was doing the wrong with the amalgamation library concerning weak stubs. A regression test has been added and new binaries have been uploaded to https://justine.lol/cosmopolitan/ Ideally this should be fixed by building a tool that turns multiple .a files into a single .a file with deduplication. As a workaround for now the cosmopolitan.a build is restructured to not include LIBC_STUBS which meant technical debt needed to be paid off where non-stub interfaces were moved to LIBC_INTRIN and LIBC_NEXGEN32E. Thank @PerfectProductions in #31 for the report!
This commit is contained in:
parent
04f1d89f84
commit
9f68d6eee9
121 changed files with 302 additions and 381 deletions
36
libc/nexgen32e/errno.S
Normal file
36
libc/nexgen32e/errno.S
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
/ Global variable for last error.
|
||||
/
|
||||
/ The system call wrappers update this with WIN32 error codes.
|
||||
/ Unlike traditional libraries, Cosmopolitan error codes are
|
||||
/ defined as variables. By convention, system calls and other
|
||||
/ functions do not update this variable when nothing's broken.
|
||||
/
|
||||
/ @see libc/sysv/consts.sh
|
||||
/ @see libc/sysv/errfuns.h
|
||||
/ @see __errno_location() stable abi
|
||||
.bss
|
||||
.align 4
|
||||
errno: .long 0
|
||||
.endobj errno,globl
|
||||
yoink __errno_location
|
28
libc/nexgen32e/errnolocation.S
Normal file
28
libc/nexgen32e/errnolocation.S
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
.keep.text # gdb needs it
|
||||
|
||||
/ Returns address of errno variable.
|
||||
/ @note this isn't a universal definition
|
||||
__errno_location:
|
||||
ezlea errno,ax
|
||||
ret
|
||||
.endfn __errno_location,globl,hidden
|
31
libc/nexgen32e/fentry.S
Normal file
31
libc/nexgen32e/fentry.S
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.real
|
||||
.source __FILE__
|
||||
.code16 # ∩ .code32 ∩ .code64
|
||||
|
||||
/ Function entry hook stub.
|
||||
/
|
||||
/ @note cc -pg -mfentry adds this to the start of every function
|
||||
/ @see libc/log/shadowargs.ncabi.c
|
||||
/ @mode long,legacy,real
|
||||
__fentry__:
|
||||
ret
|
||||
.endfn __fentry__,weak
|
27
libc/nexgen32e/mcount.S
Normal file
27
libc/nexgen32e/mcount.S
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.real
|
||||
.source __FILE__
|
||||
.code16 # ∩ .code32 ∩ .code64
|
||||
|
||||
/ Function Profiling Hook.
|
||||
/ cc -pg adds this to the start of global functions.
|
||||
mcount: ret
|
||||
.endfn mcount,weak
|
28
libc/nexgen32e/missingno.S
Normal file
28
libc/nexgen32e/missingno.S
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.real
|
||||
.source __FILE__
|
||||
.code16 # ∩ .code32 ∩ .code64
|
||||
|
||||
/ Optional function stub.
|
||||
missingno:
|
||||
xor %ax,%ax
|
||||
ret
|
||||
.endfn missingno,globl,hidden
|
|
@ -18,7 +18,6 @@ LIBC_NEXGEN32E_A_SRCS = \
|
|||
$(LIBC_NEXGEN32E_A_SRCS_C)
|
||||
|
||||
LIBC_NEXGEN32E_A_OBJS = \
|
||||
$(LIBC_NEXGEN32E_A_SRCS:%=o/$(MODE)/%.zip.o) \
|
||||
$(LIBC_NEXGEN32E_A_SRCS_A:%.s=o/$(MODE)/%.o) \
|
||||
$(LIBC_NEXGEN32E_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(LIBC_NEXGEN32E_A_SRCS_C:%.c=o/$(MODE)/%.o)
|
||||
|
|
41
libc/nexgen32e/triplf.S
Normal file
41
libc/nexgen32e/triplf.S
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/macros.internal.h"
|
||||
#include "ape/config.h"
|
||||
.real
|
||||
.source __FILE__
|
||||
.code16 # ∩ .code32 ∩ .code64
|
||||
|
||||
/ Hoses interrupt descriptor table and triple-faults the system.
|
||||
/
|
||||
/ @see youtu.be/GIKfEAF2Yhw?t=67
|
||||
/ @mode long,legacy,real
|
||||
triplf: push %bp
|
||||
mov %sp,%bp
|
||||
sub $8,%sp
|
||||
movpp %bp,%si
|
||||
lea -8(%bp),%di
|
||||
pushpop 8,%cx
|
||||
xor %ax,%ax
|
||||
rep stosb
|
||||
0: cli
|
||||
lidt -8(%bp)
|
||||
ud2
|
||||
jmp 0b
|
||||
.endfn triplf,globl,protected
|
49
libc/nexgen32e/zip.S
Normal file
49
libc/nexgen32e/zip.S
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/zip.h"
|
||||
|
||||
/ ZIP Central Directory.
|
||||
.section .piro.data.sort.zip.3,"a",@progbits
|
||||
.hidden __zip_start
|
||||
.globl __zip_start
|
||||
.type __zip_start,@object
|
||||
.align kZipCdirAlign
|
||||
__zip_start:
|
||||
.previous/*
|
||||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .piro.data.sort.zip.5,"a",@progbits
|
||||
.align kZipCdirAlign
|
||||
__zip_end:
|
||||
.long kZipCdirHdrMagic # magic
|
||||
.short 0 # disk
|
||||
.short 0 # starting disk
|
||||
.short v_zip_records # records on disk
|
||||
.short v_zip_records # records
|
||||
.long v_zip_cdirsize # size of central directory
|
||||
.long RVA(__zip_start) # central directory offset
|
||||
.short v_zip_commentsize # comment size
|
||||
.endobj __zip_end,globl,hidden
|
||||
.weak v_zip_records
|
||||
.weak v_zip_cdirsize
|
||||
.weak v_zip_commentsize
|
||||
.previous
|
Loading…
Add table
Add a link
Reference in a new issue