mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 19:28:29 +00:00
Make improvements
- Add GetCpuCount() API to redbean - Add unix.gmtime() API to redbean - Add unix.readlink() API to redbean - Add unix.localtime() API to redbean - Perfect the new redbean UNIX module APIs - Integrate with Linux clock_gettime() vDSO - Run Lua garbage collector when malloc() fails - Fix another regression quirk with linenoise repl - Fix GetProgramExecutableName() for systemwide installs - Fix a build flake with test/libc/mem/test.mk SRCS list
This commit is contained in:
parent
860ea18a87
commit
d57b81aac7
51 changed files with 3096 additions and 1395 deletions
32
tool/decode/dumpvdso.c
Normal file
32
tool/decode/dumpvdso.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 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/calls/calls.h"
|
||||
#include "libc/elf/struct/ehdr.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
|
||||
noasan int main(int argc, char *argv[]) {
|
||||
int i = 0;
|
||||
Elf64_Ehdr *ehdr = (Elf64_Ehdr *)getauxval(AT_SYSINFO_EHDR);
|
||||
if (isatty(1)) exit(1);
|
||||
for (;;) {
|
||||
write(1, ((char *)ehdr) + i++, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -27,8 +27,10 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
@ -231,6 +233,21 @@ static void printelfsymboltable(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void printelfdynsymboltable(void) {
|
||||
size_t i, symcount = 0;
|
||||
Elf64_Sym *symtab = GetElfDynSymbolTable(elf, st->st_size, &symcount);
|
||||
char *strtab = GetElfDynStringTable(elf, st->st_size);
|
||||
char *shstrtab = GetElfSectionNameStringTable(elf, st->st_size);
|
||||
if (symtab && strtab) {
|
||||
printf("\n\n");
|
||||
printf("\t.org\t%#x\n", (intptr_t)symtab - (intptr_t)elf);
|
||||
for (i = 0; i < symcount; ++i) {
|
||||
printf(".Lsym%d:\n", i);
|
||||
printelfsymbol(&symtab[i], strtab, shstrtab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static char *getelfsymbolname(const Elf64_Ehdr *elf, size_t mapsize,
|
||||
const char *strtab, const char *shstrtab,
|
||||
const Elf64_Sym *sym) {
|
||||
|
@ -324,12 +341,14 @@ int main(int argc, char *argv[]) {
|
|||
fprintf(stderr, "error: not an elf executable: %'s\n", path);
|
||||
exit(1);
|
||||
}
|
||||
elf = (Elf64_Ehdr *)getauxval(AT_SYSINFO_EHDR);
|
||||
startfile();
|
||||
printelfehdr();
|
||||
printelfsegmentheaders();
|
||||
printelfsectionheaders();
|
||||
printelfrelocations();
|
||||
printelfsymboltable();
|
||||
printelfdynsymboltable();
|
||||
munmap(elf, st->st_size);
|
||||
close(fd);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue