From b3e20fc324761dc606255524a6b75ff51c5f8c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Moln=C3=A1r?= Date: Thu, 18 May 2006 15:18:13 +0200 Subject: [PATCH] arm/pe: no need to try to precompute the size of relocations --- src/p_armpe.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/p_armpe.cpp b/src/p_armpe.cpp index c1830826..ff1168ef 100644 --- a/src/p_armpe.cpp +++ b/src/p_armpe.cpp @@ -1892,13 +1892,10 @@ void PackArmPe::pack(OutputFile *fo) const unsigned ncsection = (s1addr + s1size + oam1) &~ oam1; const unsigned upxsection = s1addr + ic + clen; - const unsigned assumed_soxrelocs = !isdll ? 0 : - ALIGN_UP(8 + 2 * (3 + (ft.id ? 2 : 0) + (sorelocs ? 1 : 0) + 2), 4); - const unsigned myimport = ncsection + assumed_soxrelocs + soresources - rvamin; - Reloc rel(1024); // new relocations are put here // patch loader - rpatch_le32(loader, codesize, "ONAM", ih.imagebase + myimport + rvamin, rel, upxsection); + // the exact value of "ONAM" can not be computed here, so we set it later + int onam_offset = rpatch_le32(loader, codesize, "ONAM", 0, rel, upxsection); rpatch_le32(loader, codesize, "BIMP", ih.imagebase + rvamin + cimports, rel, upxsection); if (sorelocs) @@ -1971,8 +1968,8 @@ void PackArmPe::pack(OutputFile *fo) } ic += soexport; - if (isdll && soxrelocs != assumed_soxrelocs) - throwInternalError("FIXME: soxrelocs != assumed_soxrelocs"); + const unsigned onam = ncsection + soxrelocs + soresources + ih.imagebase; + set_le32(loader + onam_offset, onam); // this is computed here, because soxrelocs changes some lines above const unsigned ncsize = soxrelocs + soresources + soimpdlls + soexport;