mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Add support for symbol table in .com files
This change fixes minor bugs and adds a feature, which lets us store the ELF symbol table, inside the ZIP directory. We use the path /zip/.symtab which can be safely removed using a zip editing tool, to make the binary smaller after compilation. This supplements the existing method of using a separate .com.dbg file, which is still supported. The intent is people don't always know that it's a good idea to download the debug file. It's not great having someone's first experience be a crash report, that only has numbers rather than symbols. This will help fix that!
This commit is contained in:
parent
393ca4be40
commit
23b72eb617
61 changed files with 963 additions and 510 deletions
|
@ -23,6 +23,7 @@
|
|||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
|
@ -71,7 +72,7 @@ struct Zipos *__zipos_get(void) {
|
|||
if (!once) {
|
||||
sigfillset(&neu);
|
||||
sigprocmask(SIG_BLOCK, &neu, &old);
|
||||
if ((fd = open(program_executable_name, O_RDONLY)) != -1) {
|
||||
if ((fd = open(GetProgramExecutableName(), O_RDONLY)) != -1) {
|
||||
if ((size = getfiledescriptorsize(fd)) != SIZE_MAX &&
|
||||
(map = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0)) != MAP_FAILED) {
|
||||
if ((base = FindEmbeddedApe(map, size))) {
|
||||
|
@ -83,12 +84,18 @@ struct Zipos *__zipos_get(void) {
|
|||
__zipos_munmap_unneeded(base, cdir, map);
|
||||
zipos.map = base;
|
||||
zipos.cdir = cdir;
|
||||
STRACE("__zipos_get(%#s)", program_executable_name);
|
||||
} else {
|
||||
munmap(map, size);
|
||||
kprintf("__zipos_get(%#s) → eocd not found%n",
|
||||
program_executable_name);
|
||||
STRACE("__zipos_get(%#s) → eocd not found", program_executable_name);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
} else {
|
||||
kprintf("__zipos_get(%#s) → open failed %m%n", program_executable_name);
|
||||
STRACE("__zipos_get(%#s) → open failed %m", program_executable_name);
|
||||
}
|
||||
once = true;
|
||||
sigprocmask(SIG_SETMASK, &old, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue