mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Get garbage collector working on aarch64
Garbage collection will now happen on arm64 when a function returns, rather than kicking the can down the road to when the process exits. This change also does some code cleanup and incorporates suggestions
This commit is contained in:
parent
9793d3524f
commit
01fd655097
16 changed files with 144 additions and 323 deletions
|
@ -18,10 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/sections.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/elf.h"
|
||||
#include "libc/elf/struct/ehdr.h"
|
||||
#include "libc/elf/struct/sym.h"
|
||||
#include "libc/elf/tinyelf.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -32,23 +29,6 @@
|
|||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
static bool GetElfSymbolValue(const Elf64_Ehdr *ehdr, size_t esize,
|
||||
const char *name, uint64_t *res) {
|
||||
Elf64_Xword i, n;
|
||||
const char *stab;
|
||||
const Elf64_Sym *st;
|
||||
if ((stab = GetElfStringTable(ehdr, esize)) &&
|
||||
(st = GetElfSymbolTable(ehdr, esize, &n))) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (!strcmp(stab + st[i].st_name, name)) {
|
||||
*res = st[i].st_value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsMyDebugBinaryImpl(const char *path) {
|
||||
int fd;
|
||||
void *map;
|
||||
|
@ -61,8 +41,8 @@ static bool IsMyDebugBinaryImpl(const char *path) {
|
|||
// which is currently running in memory.
|
||||
if ((size = lseek(fd, 0, SEEK_END)) != -1 &&
|
||||
(map = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0)) != MAP_FAILED) {
|
||||
if (IsElf64Binary(map, size) &&
|
||||
GetElfSymbolValue(map, size, "_etext", &value)) {
|
||||
if (READ32LE(map) == READ32LE("\177ELF") &&
|
||||
GetElfSymbolValue(map, "_etext", &value)) {
|
||||
res = !_etext || value == (uintptr_t)_etext;
|
||||
}
|
||||
munmap(map, size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue