From 033585d6755a19308314b89f1252ec1438e24fe0 Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Tue, 18 Oct 2011 16:05:38 -0400 Subject: [PATCH] 5l, 6l, 8l: correct ELFRESERVE diagnostic If the length of the interpreter string pushes us over the ELFRESERVE limit, the resulting error message will be comical. I was doing some ELF tinkering with a modified version of 8l when I hit this. To be clear, the stock linkers wouldn't hit this without adding about forty more section headers. We're safe for now. ;) Also, remove a redundant call to cflush. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5268044 --- src/cmd/5l/asm.c | 4 ++-- src/cmd/6l/asm.c | 4 ++-- src/cmd/8l/asm.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/5l/asm.c b/src/cmd/5l/asm.c index 46fb6b63236..f7fa688be19 100644 --- a/src/cmd/5l/asm.c +++ b/src/cmd/5l/asm.c @@ -632,8 +632,8 @@ asmb(void) a += elfwritehdr(); a += elfwritephdrs(); a += elfwriteshdrs(); - cflush(); - if(a+elfwriteinterp() > ELFRESERVE) + a += elfwriteinterp(); + if(a > ELFRESERVE) diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); break; } diff --git a/src/cmd/6l/asm.c b/src/cmd/6l/asm.c index dfb065e51cd..8c6bab83997 100644 --- a/src/cmd/6l/asm.c +++ b/src/cmd/6l/asm.c @@ -1095,8 +1095,8 @@ asmb(void) a += elfwritehdr(); a += elfwritephdrs(); a += elfwriteshdrs(); - cflush(); - if(a+elfwriteinterp() > ELFRESERVE) + a += elfwriteinterp(); + if(a > ELFRESERVE) diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); break; case Hwindows: diff --git a/src/cmd/8l/asm.c b/src/cmd/8l/asm.c index 119c8364b0a..948d4889ca7 100644 --- a/src/cmd/8l/asm.c +++ b/src/cmd/8l/asm.c @@ -1160,8 +1160,8 @@ asmb(void) a += elfwritehdr(); a += elfwritephdrs(); a += elfwriteshdrs(); - cflush(); - if(a+elfwriteinterp() > ELFRESERVE) + a += elfwriteinterp(); + if(a > ELFRESERVE) diag("ELFRESERVE too small: %d > %d", a, ELFRESERVE); break;