2020-06-15 14:18:57 +00:00
|
|
|
#ifndef COSMOPOLITAN_TOOL_BUILD_LIB_ELFWRITER_H_
|
|
|
|
#define COSMOPOLITAN_TOOL_BUILD_LIB_ELFWRITER_H_
|
2021-09-04 22:44:00 +00:00
|
|
|
#include "libc/calls/struct/timespec.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
#include "libc/elf/struct/ehdr.h"
|
|
|
|
#include "libc/elf/struct/rela.h"
|
|
|
|
#include "libc/elf/struct/shdr.h"
|
|
|
|
#include "libc/elf/struct/sym.h"
|
|
|
|
#include "tool/build/lib/interner.h"
|
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
2021-02-03 18:50:08 +00:00
|
|
|
struct ElfWriterSyms {
|
|
|
|
size_t i, n;
|
|
|
|
Elf64_Sym *p;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ElfWriterSymOrder {
|
|
|
|
kElfWriterSymSection,
|
|
|
|
kElfWriterSymLocal,
|
|
|
|
kElfWriterSymGlobal
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ElfWriterSymRef {
|
|
|
|
int slg;
|
|
|
|
uint32_t sym;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ElfWriterRela {
|
|
|
|
uint64_t offset;
|
|
|
|
struct ElfWriterSymRef symkey;
|
|
|
|
uint32_t type;
|
|
|
|
int64_t addend;
|
|
|
|
};
|
|
|
|
|
2020-06-15 14:18:57 +00:00
|
|
|
struct ElfWriter {
|
|
|
|
char *path;
|
|
|
|
int fd;
|
|
|
|
void *map;
|
|
|
|
size_t mapsize;
|
|
|
|
size_t wrote;
|
|
|
|
size_t entsize;
|
|
|
|
size_t addralign;
|
|
|
|
struct Elf64_Ehdr *ehdr;
|
|
|
|
struct {
|
|
|
|
size_t i, n;
|
|
|
|
Elf64_Shdr *p;
|
|
|
|
} shdrs[1];
|
2021-02-03 18:50:08 +00:00
|
|
|
struct ElfWriterSyms syms[3][1];
|
2020-06-15 14:18:57 +00:00
|
|
|
struct {
|
|
|
|
size_t i, j, n;
|
2021-09-04 22:44:00 +00:00
|
|
|
struct ElfWriterRela *p;
|
2020-06-15 14:18:57 +00:00
|
|
|
} relas[1];
|
|
|
|
struct Interner *strtab;
|
|
|
|
struct Interner *shstrtab;
|
|
|
|
};
|
|
|
|
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
struct ElfWriter *elfwriter_open(const char *, int) dontdiscard;
|
2020-06-15 14:18:57 +00:00
|
|
|
void elfwriter_cargoculting(struct ElfWriter *);
|
|
|
|
void elfwriter_close(struct ElfWriter *);
|
|
|
|
void elfwriter_align(struct ElfWriter *, size_t, size_t);
|
|
|
|
size_t elfwriter_startsection(struct ElfWriter *, const char *, int, int);
|
|
|
|
void *elfwriter_reserve(struct ElfWriter *, size_t);
|
|
|
|
void elfwriter_commit(struct ElfWriter *, size_t);
|
|
|
|
void elfwriter_finishsection(struct ElfWriter *);
|
|
|
|
void elfwriter_appendrela(struct ElfWriter *, uint64_t, struct ElfWriterSymRef,
|
|
|
|
uint32_t, int64_t);
|
|
|
|
struct ElfWriterSymRef elfwriter_linksym(struct ElfWriter *, const char *, int,
|
|
|
|
int);
|
|
|
|
struct ElfWriterSymRef elfwriter_appendsym(struct ElfWriter *, const char *,
|
|
|
|
int, int, size_t, size_t);
|
2021-09-05 08:20:03 +00:00
|
|
|
void elfwriter_yoink(struct ElfWriter *, const char *, int);
|
2020-12-24 07:42:56 +00:00
|
|
|
void elfwriter_setsection(struct ElfWriter *, struct ElfWriterSymRef, uint16_t);
|
2021-09-04 22:44:00 +00:00
|
|
|
void elfwriter_zip(struct ElfWriter *, const char *, const char *, size_t,
|
|
|
|
const void *, size_t, uint32_t, struct timespec,
|
2022-04-24 16:59:22 +00:00
|
|
|
struct timespec, struct timespec, bool, uint64_t, size_t);
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_TOOL_BUILD_LIB_ELFWRITER_H_ */
|