public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tamar Christina <Tamar.Christina@arm.com>
To: Jan Beulich <jbeulich@suse.com>, Mark Harmstone <mark@harmstone.com>
Cc: "binutils@sourceware.org" <binutils@sourceware.org>,
	"wej22007@outlook.com" <wej22007@outlook.com>,
	"zac.walker@linaro.org" <zac.walker@linaro.org>
Subject: RE: [PATCH 1/5] Fix size of external_reloc for pe-aarch64
Date: Tue, 20 Dec 2022 13:38:34 +0000	[thread overview]
Message-ID: <VI1PR08MB5325233A78EBDEC17BCFFFFEFFEA9@VI1PR08MB5325.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <0bdeeb13-acca-668f-09b5-709884267ebd@suse.com>

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: Tuesday, December 20, 2022 1:10 PM
> To: Mark Harmstone <mark@harmstone.com>
> Cc: binutils@sourceware.org; wej22007@outlook.com;
> zac.walker@linaro.org; Tamar Christina <Tamar.Christina@arm.com>
> Subject: Re: [PATCH 1/5] Fix size of external_reloc for pe-aarch64
> 
> On 20.12.2022 13:59, Mark Harmstone wrote:
> > On 16/12/22 10:47, Tamar Christina wrote:
> >>
> >> The code was taken from the Arm port which weirdly had a different
> >> size for this whether it was a WINCE target or not.  For WINCE target it has
> 10, but for
> >> everything else 14 (See include/coff/arm.h).   Since I didn't have
> relocations
> >> support anyway (the original intention was only to support objcopy
> >> workflow) I didn't dig too deeply into why Arm has it as 14 and the extra
> field.
> >>
> >> That said 10 looks to be the correct value.
> >>
> >> Thanks,
> >> Tamar
> >
> > Thanks Tamar. Sorry, I should have copied you in in the first place.
> >
> > I can't remember the specifics, but I definitely needed this patch to get
> EXEs working on Windows.
> 
> But EXEs don't use this kind of relocation; the base relocations (fixups) used
> there are encoded in an entirely different way. The relocs here should
> matter for are COFF object files only.

Agreed, the relocs here are COFF only.  That said 10 still looks like the correct value.
Microsoft's documentation seems to have become a bit unclear after they reworded it for ASLR support.
Originally the Image files didn't have relocations as by then they would have been resolved already, but for ASLR
there is exposed a .reloc section now so the loader can do the fixups.  That's what the docs now describe:
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-reloc-section-image-only

They however no longer describe COFF relocations at all.  If we find an older spec (like Revision 6.0 - February 1999),
when it was still doc/pdf like https://courses.cs.washington.edu/courses/cse378/03wi/lectures/LinkerFiles/coff.pdf 
you'll see that the COFF relocations are described in section 5.2 are still 10 bytes long.

This also coincides with LLVM's description of the COFF relocations https://llvm.org/doxygen/structllvm_1_1COFF_1_1relocation.html

It's highly likely that there is a bug in the Arm port, because the most used PE target on Arm is WINCE which sets 10.

Cheers,
Tamar

> Jan

      reply	other threads:[~2022-12-20 13:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  2:13 Mark Harmstone
2022-12-16  2:13 ` [PATCH 2/5] Skip ELF-specific tests when targeting pe-aarch64 Mark Harmstone
2022-12-16  7:07   ` Jan Beulich
2022-12-21 20:19     ` Mark Harmstone
2022-12-22  7:38       ` Jan Beulich
2022-12-16  2:13 ` [PATCH 3/5] Add pe-aarch64 relocations Mark Harmstone
2022-12-16  2:13 ` [PATCH 4/5] Add .secrel32 for pe-aarch64 Mark Harmstone
2022-12-16  2:14 ` [PATCH 5/5] Add aarch64-w64-mingw32 target Mark Harmstone
2022-12-16  7:28   ` Jan Beulich
2022-12-18 22:44     ` Martin Storsjö
2022-12-20 13:18       ` Mark Harmstone
2022-12-16  7:03 ` [PATCH 1/5] Fix size of external_reloc for pe-aarch64 Jan Beulich
2022-12-16 10:47   ` Tamar Christina
2022-12-20 12:59     ` Mark Harmstone
2022-12-20 13:10       ` Jan Beulich
2022-12-20 13:38         ` Tamar Christina [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR08MB5325233A78EBDEC17BCFFFFEFFEA9@VI1PR08MB5325.eurprd08.prod.outlook.com \
    --to=tamar.christina@arm.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=mark@harmstone.com \
    --cc=wej22007@outlook.com \
    --cc=zac.walker@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).