Fix unzip warning with apelink generated symtabs

This commit is contained in:
Justine Tunney 2023-11-18 16:56:11 -08:00
parent 3e6d536822
commit 0c89516ac5
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
17 changed files with 192 additions and 59 deletions

View file

@ -674,9 +674,10 @@ static void LoadSymbols(Elf64_Ehdr *e, Elf64_Off size, const char *path) {
unsigned char *cfile = Malloc(cfile_size);
bzero(cfile, cfile_size);
WRITE32LE(cfile, kZipCfileHdrMagic);
cfile[4] = kZipCosmopolitanVersion;
cfile[5] = kZipOsUnix;
cfile[6] = kZipEra2001;
WRITE16LE(cfile + kZipCfileOffsetVersionMadeBy,
kZipOsUnix << 8 | kZipCosmopolitanVersion);
WRITE16LE(cfile + kZipCfileOffsetVersionNeeded, kZipEra2001);
WRITE16LE(cfile + kZipCfileOffsetGeneralflag, kZipGflagUtf8);
WRITE16LE(cfile + kZipCfileOffsetCompressionmethod, kZipCompressionDeflate);
WRITE16LE(cfile + kZipCfileOffsetLastmodifieddate, DOS_DATE(2023, 7, 29));
WRITE16LE(cfile + kZipCfileOffsetLastmodifiedtime, DOS_TIME(0, 0, 0));
@ -1813,9 +1814,11 @@ int main(int argc, char *argv[]) {
int i, j;
Elf64_Off offset;
Elf64_Xword prologue_bytes;
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif
prog = argv[0];
if (!prog) prog = "apelink";
@ -2080,7 +2083,8 @@ int main(int argc, char *argv[]) {
p = stpcpy(p, " count=");
loader->ddarg_size1 = p;
p = GenerateDecimalOffsetRelocation(p);
p = stpcpy(p, " bs=1 2>/dev/null | gzip -dc >\"$t.$$\" ||exit\n");
p = stpcpy(
p, " bs=1 2>/dev/null | /usr/bin/gzip -dc >\"$t.$$\" ||exit\n");
if (loader->macho_offset) {
p = stpcpy(p, "/bin/dd if=\"$t.$$\" of=\"$t.$$\"");
p = stpcpy(p, " skip=");

View file

@ -294,7 +294,7 @@ int main(int argc, char *argv[]) {
struct ar_hdr header1;
struct ar_hdr header2;
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif

View file

@ -837,7 +837,7 @@ int main(int argc, char *argv[]) {
char *s, *q, **envp;
int ws, opt, exitcode;
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif

View file

@ -1078,7 +1078,7 @@ static void Pwrite(int fd, const void *data, size_t size, uint64_t offset) {
}
int main(int argc, char *argv[]) {
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif
// get program name

View file

@ -124,6 +124,8 @@ static const uint32_t kSourceExts[] = {
EXT("c"), // c
EXT("cc"), // c++
EXT("cpp"), // c++
EXT("cu"), // cuda
EXT("m"), // objective c
};
static char *names;
@ -667,7 +669,7 @@ int main(int argc, char *argv[]) {
ssize_t rc;
size_t i, n;
char *makefile;
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif
prog = argv[0];

View file

@ -71,7 +71,7 @@
" INPUT is an elf executable made by the unix linker\n" \
"\n"
#ifndef NDEBUG
#ifdef MODE_DBG
#define DEBUG(...) kprintf("DEBUG: " __VA_ARGS__)
#else
#define DEBUG(...) (void)0

View file

@ -114,7 +114,7 @@ struct Packages {
Elf64_Xword symcount; // not persisted
int section_offset;
int section_count;
} * p;
} *p;
} objects;
struct Sections {
size_t i, n;
@ -128,7 +128,7 @@ struct Packages {
kBss,
kOther,
} kind;
} * p;
} *p;
} sections;
struct Symbols {
size_t i, n;
@ -139,9 +139,9 @@ struct Packages {
uint8_t type : 4;
uint16_t object; // pkg->objects.p[object]
uint16_t section; // pkg->sections.p[section]
} * p; // persisted as pkg+RVA
} *p; // persisted as pkg+RVA
} symbols, undefs; // TODO(jart): hash undefs?
} * *p; // persisted across multiple files
} **p; // persisted across multiple files
};
struct Relas {
@ -150,7 +150,7 @@ struct Relas {
struct Rela {
const char *symbol_name;
const char *object_path;
} * p;
} *p;
} prtu;
static wontreturn void Die(const char *path, const char *reason) {
@ -649,7 +649,7 @@ int main(int argc, char *argv[]) {
if (argc == 2 && !strcmp(argv[1], "-n")) {
exit(0);
}
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif
bzero(&pkg, sizeof(pkg));

View file

@ -312,7 +312,7 @@ int main(int argc, char *argv[]) {
void *map;
ssize_t size;
const char *path;
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif
for (i = 1; i < argc; ++i) {

View file

@ -809,7 +809,7 @@ int main(int argc, char *argv[]) {
if (g_daemonize) Daemonize();
Serve();
free(g_psk);
#if IsModeDbg()
#ifdef MODE_DBG
CheckForMemoryLeaks();
CheckForFileLeaks();
#endif

View file

@ -211,7 +211,7 @@ static void CopyZip(void) {
}
int main(int argc, char *argv[]) {
#ifndef NDEBUG
#ifdef MODE_DBG
ShowCrashReports();
#endif
prog = argv[0];