delorie.com/archives/browse.cgi | search |
DMARC-Filter: | OpenDMARC Filter v1.4.2 delorie.com 56LCVn2Z2854993 |
Authentication-Results: | delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com |
Authentication-Results: | delorie.com; spf=pass smtp.mailfrom=cygwin.com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 delorie.com 56LCVn2Z2854993 |
Authentication-Results: | delorie.com; |
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=c8wB/8wp | |
X-Recipient: | archive-cygwin AT delorie DOT com |
DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org C91353858CD1 |
DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
s=default; t=1753101106; | |
bh=ZxUeUGN9Lu4MREXwpY7N7P1/78EB6Ouuj759/mooNu4=; | |
h=References:In-Reply-To:Date:Subject:To:Cc:List-Id: | |
List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: | |
From:Reply-To:From; | |
b=c8wB/8wpRBJ1WD/EwZ39EXqEQvXrCRRSV1mb9Sd/Etyd2cHNm4tRHrPdsgbWRy7vy | |
YQ5sbe49NDc31Ydcd1/D0OdtcW2RQO/XS5+1Zdxm4EFMvqH8ptIteOJIvYS0S8PMuw | |
nW98ojkLgjtLNjYVc0/d2VrLhFIWjJSBW7JdyPRc= | |
X-Original-To: | cygwin AT cygwin DOT com |
Delivered-To: | cygwin AT cygwin DOT com |
DMARC-Filter: | OpenDMARC Filter v1.4.2 sourceware.org 088D73858D1E |
ARC-Filter: | OpenARC Filter v1.0.0 sourceware.org 088D73858D1E |
ARC-Seal: | i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1753101081; cv=none; |
b=IH2pVoo1F5hj02OhyAx6Wyi9590gXINQA1ueSVWo16i0YuNAFaxRwcpYfZK9o0ypaf9TDaqtYx4db04rKhWJK80cKTaGW/gH5fwATGCwFuM8MP6XckgEt0vZ1ye/HPUkJmkCU0aj5BgqHWtowqayXw3DmDw/Ht9yuvrEpUS6HbE= | |
ARC-Message-Signature: | i=1; a=rsa-sha256; d=sourceware.org; s=key; |
t=1753101081; c=relaxed/simple; | |
bh=KUwkd7qR83lKt7cCKDuL8h5NlhduKPOd4aE54vk3ITM=; | |
h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; | |
b=ije/zLs2r+0TXHU+f/hdxBqvgF9MklknErVGoCpEePYRll1SYKPCayv4xuXjKBGBPryqN7e1UGhbHNwO/Laj1QPVvLc0cqrus3t2ijt7eEpbmFAiPSBNuQjNZz0CLB0pOPVGa+BRZIznUaboHW8pOgdlvYax8fvY3Feolr+J9eo= | |
ARC-Authentication-Results: | i=1; server2.sourceware.org |
DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 088D73858D1E |
X-Google-DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; |
d=1e100.net; s=20230601; t=1753101080; x=1753705880; | |
h=cc:to:subject:message-id:date:from:in-reply-to:references | |
:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id | |
:reply-to; | |
bh=srW52SOzKi/fxeHQ1PB/RNPisLMOr7I17S18rDDvfAM=; | |
b=eW8RXJDzs4E4od5lil4VaIiv+/DAb/S97c1n9gYLiWkQS0zs4Uc/9P+7qGEN+PMQQU | |
LDK6dvzNC0aTjwaRgeMYyQL1U60oQ7Dj0FiQ609jm91tGoJrZhQZ8mzj1/6dXwYgjS+/ | |
rCfiX+foc+R6W24UfsUNmiSek8Ft2qBK/k39qeSMLCOylPzovE8FMthv8xrWXTRU0xhO | |
Q/zE8Q2YVboIIvMnWk7vi5+H0OIvoAcCmPFLTOO7YtuKW2k+9ryKlWVt09sKrkDc5l4U | |
vyNzHJ8Y+7OlLWPY5xZfW4scAkeEUe9qwIA4RBdPwWjrf8HrMpdnD94WlDvd/pvniXhX | |
eyBw== | |
X-Gm-Message-State: | AOJu0Yx1lMdum3SFrYPLqnHJLqs1Iz59R4v9j0UuIH1Y82SxWm2ijYGv |
ADuxyJ4rnj3ZamvtKoHYLT91Spw9wHiMIxN4Xd/zOV/fEWrQA372sNzrq9M90rBxAkox4THwZNz | |
LGyICdvASxdRYzIfVTqNSFju1xucUDo0QHKFY | |
X-Gm-Gg: | ASbGnct1CKlRkJlOS2wtd0IJq6G8G464ttR/RXo6//PLwTTHiTkWra/Qvp5oPjAUWcB |
FMf1CfMnmMYhXPmtmbLehbMfxBuar8nEJxMndNYSlkonzDTBGI0etoqp2Fj3vgj4qZhiOMnLxc/ | |
E/pdHqtzzD6GVKkP/mLfjTZ4r+i+Axp9bD6cKQLv5DwNXP745mE5gFY+Kp70F4G9dK1pW1N5I8W | |
u5Mg8B56gA0r9Z7k0k9NSkj/ZIVTCPRjFoU0DBO | |
X-Google-Smtp-Source: | AGHT+IEaNF/Tqv8Oiz89dJs4l2DEEPwn2MfkWCWgFCyyi2pZYfkr0Yktq8IsjzmROanY0+G4Ln19J39v6Q5ZJ/njxe0= |
X-Received: | by 2002:a17:90b:2803:b0:311:ad7f:3299 with SMTP id |
98e67ed59e1d1-31c9e770447mr24828705a91.25.1753101079793; Mon, 21 Jul 2025 | |
05:31:19 -0700 (PDT) | |
MIME-Version: | 1.0 |
References: | <1749211000852 DOT 785937412 DOT 3467708457 AT ezweb DOT ne DOT jp> |
<4c738bdf-be6e-38b6-897f-85b2e214636b AT jdrake DOT com> | |
In-Reply-To: | <4c738bdf-be6e-38b6-897f-85b2e214636b@jdrake.com> |
Date: | Mon, 21 Jul 2025 21:31:05 +0900 |
X-Gm-Features: | Ac12FXyojkntEoMKxVmCLCES9rXZWGhvdNG2yfGxdqEyzlu39Qkh5XkkQmdof2E |
Message-ID: | <CAO9E=QW0xqqnzEfBexGmNKpxgRu73g8Y_wOvaHeTM6_83juVZg@mail.gmail.com> |
Subject: | Re: PE format conformance issues in rebase.exe results |
incompatibility with LLVM-lld | |
To: | Jeremy Drake <cygwin AT jdrake DOT com> |
Cc: | cygwin AT cygwin DOT com |
X-BeenThere: | cygwin AT cygwin DOT com |
X-Mailman-Version: | 2.1.30 |
List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
From: | Kashiwada Tomohiro via Cygwin <cygwin AT cygwin DOT com> |
Reply-To: | Kashiwada Tomohiro <kikairoya AT gmail DOT com> |
Sender: | "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com> |
--0000000000001e520b063a6fa7f1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I just found this in my spam folder -- along with two other emails you CCed me on earlier. I'm really sorry for the delay. Apparently, Google thinks, "You can't speak English, so any English emails to you must be spam." 2025=E5=B9=B47=E6=9C=8818=E6=97=A5(=E9=87=91) 9:36 Jeremy Drake <cygwin AT jdr= ake.com>: > > On Sat, 7 Jun 2025, kikairoya via Cygwin wrote: > > > Dear Cygwin team, > > > > I=E2=80=99ve found that rebase.exe makes certain assumptions that do no= t conform > > to the PE specification. > > > > 1. Incorrect handling of COFF File Header position > > When checking the 'Characteristics' field in the COFF File Header, > > rebase.exe assumes this field is always at a fixed offset. However, the > > PE specification states that the COFF File Header is located immediatel= y > > after the PE signature in the image file. > > > > https://cygwin.com/cgit/cygwin-apps/rebase/tree/rebase.c#n1739 > > At this point, the code should perform a relative seek of 18 bytes, not > > an absolute seek with SEEK_SET. > > > > This causes incompatibility with DLLs linked using LLVM's lld, which > > uses a PE stub of a different size. As a result, such DLLs cannot be > > rebased. > > > > > > 2. Limiting file size too conservatively > > https://cygwin.com/cgit/cygwin-apps/rebase/tree/pechecksum.c#n81 > > > > Here, the image size is limited to 1 GiB, while the PE specification > > allows for up to 2 GiB. Large DLLs with debug information (e.g., > > `cygLLVM*.dll`, `cygclang-cpp*.dll`, etc.) can easily exceed the 1 GiB > > limit. > > > > > > I hope these issues can be addressed to improve compatibility with > > LLVM-based toolchains and enhance the robustness of development > > workflows. > > > Would you like to make a patch for these? There may be another issue > because peflags says "checksum update failed" on a small lld-created exe > even when not modifying the binary. > Sure, I have made a patch. I didn't see about peflags but it should have similar logic, I can take a l= ook about that -- after bisecting clang. diff --git a/pechecksum.c b/pechecksum.c index 8695138..d9fe544 100644 --- a/pechecksum.c +++ b/pechecksum.c @@ -77,8 +77,8 @@ unsigned pe32_checksum(int fd, int set, unsigned * old_checksum) sum +=3D get_word(buf + i); sum =3D (sum + (sum >> 16)) & 0xffff; - if ((size +=3D 2) >=3D 0x40000000) { - // 1GiB, assume something is wrong. + if ((size +=3D 2) >=3D 0x80000000) { + // >=3D2GiB, assume something is wrong. errno =3D EINVAL; return 0; } diff --git a/rebase.c b/rebase.c index 6a531d0..07e8016 100644 --- a/rebase.c +++ b/rebase.c @@ -1704,7 +1704,7 @@ BOOL is_rebaseable (const char *pathname) { const int pe_signature_offset_offset =3D 0x3c; - const int pe_characteristics_offset =3D 150; + const int pe_characteristics_offset =3D 18; short int pe_signature_offset =3D 0; BOOL status =3D FALSE; int fd, size; @@ -1736,7 +1736,6 @@ is_rebaseable (const char *pathname) if (pe_sig !=3D IMAGE_NT_SIGNATURE) goto done; - lseek (fd, 0, SEEK_SET); offset =3D lseek (fd, pe_characteristics_offset, SEEK_CUR); if (offset =3D=3D -1) goto done; --0000000000001e520b063a6fa7f1 Content-Type: application/octet-stream; name="0001-fix-handling-of-PE-header-and-size-limit.patch" Content-Disposition: attachment; filename="0001-fix-handling-of-PE-header-and-size-limit.patch" Content-Transfer-Encoding: base64 Content-ID: <f_mdd2m9nt0> X-Attachment-Id: f_mdd2m9nt0 RnJvbSBlOTkwY2Y3ZWE3MDA5MWZjZjU1MmQyMzY3ZjBhMDBiZDgwZDEwOGY3IE1vbiBTZXAgMTcg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IGIvcmViYXNlLmMKQEAgLTE3MDQsNyArMTcwNCw3IEBAIEJPT0wKIGlzX3JlYmFz ZWFibGUgKGNvbnN0IGNoYXIgKnBhdGhuYW1lKQogewogICBjb25zdCBpbnQgcGVfc2lnbmF0dXJl X29mZnNldF9vZmZzZXQgPSAweDNjOwotICBjb25zdCBpbnQgcGVfY2hhcmFjdGVyaXN0aWNzX29m ZnNldCA9IDE1MDsKKyAgY29uc3QgaW50IHBlX2NoYXJhY3RlcmlzdGljc19vZmZzZXQgPSAxODsK ICAgc2hvcnQgaW50IHBlX3NpZ25hdHVyZV9vZmZzZXQgPSAwOwogICBCT09MIHN0YXR1cyA9IEZB TFNFOwogICBpbnQgZmQsIHNpemU7CkBAIC0xNzM2LDcgKzE3MzYsNiBAQCBpc19yZWJhc2VhYmxl IChjb25zdCBjaGFyICpwYXRobmFtZSkKICAgaWYgKHBlX3NpZyAhPSBJTUFHRV9OVF9TSUdOQVRV UkUpCiAgICAgZ290byBkb25lOwogCi0gIGxzZWVrIChmZCwgMCwgU0VFS19TRVQpOwogICBvZmZz ZXQgPSBsc2VlayAoZmQsIHBlX2NoYXJhY3RlcmlzdGljc19vZmZzZXQsIFNFRUtfQ1VSKTsKICAg aWYgKG9mZnNldCA9PSAtMSkKICAgICBnb3RvIGRvbmU7Ci0tIAoyLjQ1LjEKCg== --0000000000001e520b063a6fa7f1 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple --0000000000001e520b063a6fa7f1--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |