Re-enable apelink size optimization

I'm no longer able to reproduce the PE import table corruption that was
previously observed. Since this optimization shaves up to 64kb off each
fat APE binary we build, it's worth turning this back on again, to wait
and see if something breaks, and if so, fix it. At least until the next
release is shipped.

See #965
This commit is contained in:
Justine Tunney 2023-11-29 05:41:23 -08:00
parent ff955aaa01
commit 7b3d7ee07b
No known key found for this signature in database
GPG key ID: BE714B4575D6E328

View file

@ -28,7 +28,6 @@
#include "libc/elf/struct/phdr.h" #include "libc/elf/struct/phdr.h"
#include "libc/fmt/conv.h" #include "libc/fmt/conv.h"
#include "libc/fmt/itoa.h" #include "libc/fmt/itoa.h"
#include "libc/serialize.h"
#include "libc/limits.h" #include "libc/limits.h"
#include "libc/macho.internal.h" #include "libc/macho.internal.h"
#include "libc/macros.internal.h" #include "libc/macros.internal.h"
@ -40,6 +39,7 @@
#include "libc/nt/struct/imagesectionheader.internal.h" #include "libc/nt/struct/imagesectionheader.internal.h"
#include "libc/runtime/runtime.h" #include "libc/runtime/runtime.h"
#include "libc/runtime/symbols.internal.h" #include "libc/runtime/symbols.internal.h"
#include "libc/serialize.h"
#include "libc/stdalign.internal.h" #include "libc/stdalign.internal.h"
#include "libc/stdckdint.h" #include "libc/stdckdint.h"
#include "libc/stdio/stdio.h" #include "libc/stdio/stdio.h"
@ -1459,10 +1459,9 @@ static char *SecondPass2(char *p, struct Input *in) {
// the new file size. that's only possible if all the fat ape hdrs // the new file size. that's only possible if all the fat ape hdrs
// we generate are able to fit inside the prologue. // we generate are able to fit inside the prologue.
p = ALIGN(p, 8); p = ALIGN(p, 8);
// TODO(jart): Figure out why not skewing corrupts pe import table
in->we_must_skew_pe_vaspace = in->we_must_skew_pe_vaspace =
1 || ROUNDUP(p - prologue + in->size_of_pe_headers, ROUNDUP(p - prologue + in->size_of_pe_headers,
(int)in->pe->OptionalHeader.FileAlignment) > in->minload; (int)in->pe->OptionalHeader.FileAlignment) > in->minload;
if (!in->we_must_skew_pe_vaspace) { if (!in->we_must_skew_pe_vaspace) {
in->pe_e_lfanew = p - prologue; in->pe_e_lfanew = p - prologue;
in->pe_SizeOfHeaders = in->pe->OptionalHeader.SizeOfHeaders; in->pe_SizeOfHeaders = in->pe->OptionalHeader.SizeOfHeaders;