Skip to content

Commit

Permalink
Remove IMAGE_BASE_VIRTUAL
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Sep 12, 2023
1 parent 8a0008d commit 20c7733
Show file tree
Hide file tree
Showing 65 changed files with 10 additions and 286 deletions.
3 changes: 1 addition & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@
],
"defines": [
"COSMO",
"MODE=",
"IMAGE_BASE_VIRTUAL=0x400000"
"MODE="
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion ape/aarch64.lds
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OUTPUT_FORMAT("elf64-littleaarch64",

SECTIONS {

. = SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL);
. = SEGMENT_START("text-segment", 0x010000000000);
__executable_start = .;
. += SIZEOF_HEADERS;

Expand Down
4 changes: 4 additions & 0 deletions ape/ape.lds
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@
#define SKEW 0
#endif

#ifndef IMAGE_BASE_VIRTUAL
#define IMAGE_BASE_VIRTUAL 0x400000
#endif

#if IMAGE_BASE_VIRTUAL > 0xffffffff
#error "please use 32-bit addresses for image data"
#endif
Expand Down
8 changes: 0 additions & 8 deletions build/definitions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ else
TMPSAFE = $(TMPDIR)/
endif

ifeq ($(ARCH), aarch64)
IMAGE_BASE_VIRTUAL ?= 0x010000000000
else
IMAGE_BASE_VIRTUAL ?= 0x400000
endif

BACKTRACES = \
-fno-optimize-sibling-calls \
-mno-omit-leaf-frame-pointer
Expand Down Expand Up @@ -222,7 +216,6 @@ MATHEMATICAL = \
DEFAULT_CPPFLAGS += \
-D_COSMO_SOURCE \
-DMODE='"$(MODE)"' \
-DIMAGE_BASE_VIRTUAL=$(IMAGE_BASE_VIRTUAL) \
-nostdinc \
-iquote .

Expand Down Expand Up @@ -373,7 +366,6 @@ LINK = $(LD) $(LINK.flags)
ELF = o/libc/elf/elf.lds
ELFLINK = $(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION) && $(COMPILE) -AFIXUP.ape -T$@ $(FIXUPOBJ) $@
LINKARGS = $(patsubst %.lds,-T %.lds,$(call uniqr,$(LD.libs) $(filter-out %.pkg,$^)))
LOLSAN = build/lolsan -b $(IMAGE_BASE_VIRTUAL)

# The compiler won't generate %xmm code for sources extensioned .greg.c,
# which is needed for C modules wanting to run at the executive level or
Expand Down
17 changes: 0 additions & 17 deletions libc/calls/state.internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_
#define COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_
#include "libc/intrin/nopl.internal.h"
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
Expand All @@ -21,22 +20,6 @@ void __sig_lock(void);
void __sig_unlock(void);
void __sig_funlock(void);

#ifdef _NOPL0
#define __fds_lock() _NOPL0("__threadcalls", __fds_lock)
#define __fds_unlock() _NOPL0("__threadcalls", __fds_unlock)
#else
#define __fds_lock() (__threaded ? __fds_lock() : 0)
#define __fds_unlock() (__threaded ? __fds_unlock() : 0)
#endif

#ifdef _NOPL0
#define __sig_lock() _NOPL0("__threadcalls", __sig_lock)
#define __sig_unlock() _NOPL0("__threadcalls", __sig_unlock)
#else
#define __sig_lock() (__threaded ? __sig_lock() : 0)
#define __sig_unlock() (__threaded ? __sig_unlock() : 0)
#endif

#define __vforked (__tls_enabled && (__get_tls()->tib_flags & TIB_FLAG_VFORKED))

COSMOPOLITAN_C_END_
Expand Down
9 changes: 0 additions & 9 deletions libc/intrin/cxaatexit.internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_
#define COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_
#include "libc/intrin/nopl.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/tls.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
Expand All @@ -24,14 +23,6 @@ void __cxa_lock(void);
void __cxa_unlock(void);
void __cxa_printexits(FILE *, void *);

#ifdef _NOPL0
#define __cxa_lock() _NOPL0("__threadcalls", __cxa_lock)
#define __cxa_unlock() _NOPL0("__threadcalls", __cxa_unlock)
#else
#define __cxa_lock() (__threaded ? __cxa_lock() : 0)
#define __cxa_unlock() (__threaded ? __cxa_unlock() : 0)
#endif

COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_RUNTIME_CXAATEXIT_H_ */
77 changes: 0 additions & 77 deletions libc/intrin/nopl.internal.h

This file was deleted.

1 change: 0 additions & 1 deletion libc/log/vflogf.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "libc/runtime/runtime.h"
#include "libc/stdio/dprintf.h"
#include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/fileno.h"
Expand Down
55 changes: 0 additions & 55 deletions libc/macros.internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,35 +445,6 @@
#endif
.endm

// Good alignment for loops where alignment actually helps.
// @note 16-byte if <10 padding otherwise 8-byte
.macro .alignloop
#ifndef __OPTIMIZE_SIZE__
.p2align 4,,10
.p2align 4
#endif
.endm

// Loads Effective Address
// Supporting security blankets
.macro plea symbol:req reg64:req reg32:req
#if __PIC__ + __PIE__ + __code_model_medium__ + __code_model_large__ + 0 > 1
lea \symbol(%rip),\reg64
#else
mov $\symbol,\reg32
#endif
.endm

// Loads Effective Address to Stack
// Supporting security blankets
.macro pshaddr symbol:req
#if __PIC__ + __PIE__ + __code_model_medium__ + __code_model_large__ + 0 > 1
push $IMAGE_BASE_VIRTUAL+RVA(\symbol)(%rip),\reg64
#else
push $\symbol
#endif
.endm

// TODO(jart): delete
// Loads Effective Address
// Supporting security blankets
Expand All @@ -486,32 +457,6 @@
#endif
.endm

.macro farcall symbol:req
.type \symbol,@function
#if __PIC__ + __PIE__ + __code_model_medium__ + __code_model_large__ + 0 > 1
call *\symbol\()@gotpcrel(%rip)
#else
call \symbol\()@plt
#endif
.endm

// Pushes RVA on stack of linktime mergeable string literal.
// @see popstr
.macro pushstr text
.section .rodata.str1.1,"aSM",@progbits,1
.Lstr\@: .asciz "\text"
.endobj .Lstr\@
.previous
push $.Lstr\@ - IMAGE_BASE_VIRTUAL
.endm

// Pops off stack string address.
// @see pushstr
.macro popstr dest:req
addl $IMAGE_BASE_VIRTUAL,(%rsp)
pop \dest
.endm

// Loads address of linktime mergeable string literal into register.
.macro loadstr text:req reg:req regsz bias=0
.section .rodata.str1.1,"aSM",@progbits,1
Expand Down
1 change: 0 additions & 1 deletion libc/runtime/ftracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "libc/fmt/itoa.h"
#include "libc/intrin/cmpxchg.h"
#include "libc/intrin/kprintf.h"
#include "libc/intrin/nopl.internal.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/stackframe.h"
#include "libc/runtime/internal.h"
Expand Down
9 changes: 0 additions & 9 deletions libc/runtime/memtrack.internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define COSMOPOLITAN_LIBC_RUNTIME_MEMTRACK_H_
#include "ape/sections.internal.h"
#include "libc/dce.h"
#include "libc/intrin/nopl.internal.h"
#include "libc/macros.internal.h"
#include "libc/nt/version.h"
#include "libc/runtime/runtime.h"
Expand Down Expand Up @@ -61,14 +60,6 @@ void __release_memory_nt(struct MemoryIntervals *, int, int);
int __untrack_memories(void *, size_t);
size_t __get_memtrack_size(struct MemoryIntervals *);

#ifdef _NOPL0
#define __mmi_lock() _NOPL0("__threadcalls", __mmi_lock)
#define __mmi_unlock() _NOPL0("__threadcalls", __mmi_unlock)
#else
#define __mmi_lock() (__threaded ? __mmi_lock() : 0)
#define __mmi_unlock() (__threaded ? __mmi_unlock() : 0)
#endif

#ifdef __x86_64__
/*
* AMD64 has 48-bit signed pointers (PML4T)
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/clearerr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/feof.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/ferror.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/fflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
9 changes: 0 additions & 9 deletions libc/stdio/fflush.internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
#define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
#include "libc/intrin/nopl.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
Expand All @@ -23,14 +22,6 @@ extern pthread_mutex_t __fflush_lock_obj;
void __fflush_lock(void);
void __fflush_unlock(void);

#ifdef _NOPL0
#define __fflush_lock() _NOPL0("__threadcalls", __fflush_lock)
#define __fflush_unlock() _NOPL0("__threadcalls", __fflush_unlock)
#else
#define __fflush_lock() (__threaded ? __fflush_lock() : 0)
#define __fflush_unlock() (__threaded ? __fflush_unlock() : 0)
#endif

COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ */
1 change: 0 additions & 1 deletion libc/stdio/fgetc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/fgetln.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/internal.h"
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/fgets.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/fgetwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/fgetws.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"

/**
Expand Down
1 change: 0 additions & 1 deletion libc/stdio/fileno.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#include "libc/stdio/lock.internal.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/errfuns.h"

Expand Down
Loading

0 comments on commit 20c7733

Please sign in to comment.