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
|
@ -1,21 +1,30 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SYMBOLS_H_
|
||||
#define COSMOPOLITAN_LIBC_SYMBOLS_H_
|
||||
#include "libc/bits/bits.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define SYMBOLS_MAGIC READ32LE("SYMT")
|
||||
#define SYMBOLS_ABI 1
|
||||
|
||||
struct Symbol {
|
||||
unsigned x; /* start (relative to addr_base) */
|
||||
unsigned y; /* start + size - 1 (inclusive) */
|
||||
};
|
||||
|
||||
struct SymbolTable {
|
||||
size_t count; /* of `symbols` */
|
||||
size_t mapsize; /* of this object */
|
||||
intptr_t addr_base; /* IMAGE_BASE_VIRTUAL */
|
||||
intptr_t addr_end; /* _end - 1 */
|
||||
unsigned *names; /* relative to `name_base` */
|
||||
char *name_base; /* double-nul terminated w/ empty first */
|
||||
struct Symbol symbols[]; /* sorted and non-overlapping intervals */
|
||||
uint32_t magic; /* 0xFEEDABEE little endian */
|
||||
uint32_t abi; /* 1 */
|
||||
uint64_t count; /* of `symbols` */
|
||||
uint64_t size; /* file size */
|
||||
uint64_t mapsize; /* of this object */
|
||||
int64_t addr_base; /* IMAGE_BASE_VIRTUAL */
|
||||
int64_t addr_end; /* _end - 1 */
|
||||
uint32_t *names; /* relative to `name_base` */
|
||||
char *name_base; /* double-nul terminated w/ empty first */
|
||||
uint32_t names_offset; /* for file loading */
|
||||
uint32_t name_base_offset; /* for file loading */
|
||||
struct Symbol symbols[]; /* sorted and non-overlapping intervals */
|
||||
};
|
||||
|
||||
struct SymbolTable *GetSymbolTable(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue