cosmopolitan/libc/elf/struct/shdr.h
Justine Tunney 0c630d95b5
Rewrite Cosmopolitan Ar
The build/bootstrap/ar.com program is now tinier. This change reduces
its size from 140kb to 53kb. Nothing was traded away. Cosmopolitan Ar
performance is now 2x better than llvm-ar largely thanks to using the
copy_file_range() system call. This change homebrews a new allocation
API that addresses the shortcomings of the C standard library design.
Using these new balloc() and reballoc() functions I managed to reduce
memory consumption so much that Cosmpolitan Ar should now use roughly
100x fewer bytes of peak resident memory compared to llvm-ar. Correct
behavior with better compatibility has been assured. Binary output is
now pretty much bit-identical to llvm-ar, as of this change. This can
and should be the living proof we need to show that a better world is
possible for software.
2023-07-02 10:19:16 -07:00

52 lines
1.3 KiB
C

#ifndef COSMOPOLITAN_LIBC_ELF_STRUCT_SHDR_H_
#define COSMOPOLITAN_LIBC_ELF_STRUCT_SHDR_H_
#include "libc/elf/scalar.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
/**
* Section header.
* @see https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html
*/
typedef struct Elf64_Shdr {
Elf64_Word sh_name;
Elf64_Word sh_type; /* SHT_{PROGBITS,NOBITS,STRTAB,SYMTAB,RELA,...} */
Elf64_Xword sh_flags; /* SHF_{WRITE,ALLOC,EXECINSTR,MERGE,STRINGS,...} */
Elf64_Addr sh_addr;
Elf64_Off sh_offset;
Elf64_Xword sh_size;
/*
* Index of linked section header.
*
* If `sh_type` is `SHT_RELA` then `sh_link` holds the section header
* index of the associated symbol table.
*
* If `sh_type` is `SHT_SYMTAB` then `sh_link` holds the section
* header index of the associated string table.
*/
Elf64_Word sh_link;
/*
* If `sh_type` is `SHT_RELA` then `sh_info` contains the index of the
* section to which relocations apply.
*
* If `sh_type` is `SHT_SYMTAB` or `SHT_DYNSYM` then `sh_info`
* contains an index that's one greater than symbol table index of
* last `STB_LOCAL` symbol.
*/
Elf64_Word sh_info;
Elf64_Xword sh_addralign;
Elf64_Xword sh_entsize;
} Elf64_Shdr;
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_ELF_STRUCT_SHDR_H_ */