mcc

mcc is a machine code compiler.

Log | Files | << Repositories


tree 89eda819a28d86c8468b5ec293ffd8079704eb70
parent 13dcfa89f34d29f640b57b97e6b88f0462c38ee1
author esote <esote.net@gmail.com> 1559868615 -0500
committer esote <esote.net@gmail.com> 1559868615 -0500
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQTXAxYDuIzimYoNSPuhTmRAjzzC8gUCXSArJgAKCRChTmRAjzzC
 8mxeAP4kHjAiHeEHkNYzzxeL9j4RF+Pr79zVubsLjKRuw68V4wEA5RquOQ6BWNuU
 3MSze9lY2aLtKuW50b0x4mNTpUDqPQ8=
 =M4TQ
 -----END PGP SIGNATURE-----

Fix incorrect evaluation of memsize with large values

If the lower 32 bits of memsize were zero but not the upper 32 bits, the bss
program header and shstrtab label would not be written.

 mcc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mcc.c b/mcc.c
index 436ab49..4f78314 100644
--- a/mcc.c
+++ b/mcc.c
@@ -128,7 +128,7 @@ main(int argc, char *argv[])
 		write_phdr32_text(out, &opts);
 	}
 
-	if (opts.mem.n32 != 0) {
+	if (opts.mem.n64 != 0) {
 		if (use_64) {
 			write_phdr64_bss(out, &opts);
 		} else {
@@ -277,7 +277,7 @@ write_section_names(FILE *const out, struct mcc_opts const *const opts)
 		err(1, "write text name");
 	}
 
-	if (opts->mem.n32 != 0 && fwrite(bss, BSS_LEN, 1, out) != 1) {
+	if (opts->mem.n64 != 0 && fwrite(bss, BSS_LEN, 1, out) != 1) {
 		err(1, "write bss name");
 	}
 }