Discussion:
[PATCH] : Correct ARM_RVA32 value in pe images generation for arm Windows CE.
Pedro Alves
2006-07-04 13:28:01 UTC
Permalink
Hi all,

Please find attached a patch against ld/pe-dll.c that fixes pei .reloc
section generation for arm Windows CE targets.

The problem was that the wrong ARM_RVA32 value was filled in the
pe_details->imagebase_reloc for ARM targets.

The PE Coff specification states:
Constant - IMAGE_REL_ARM_ADDR32NB
Value - 0x0002
Description - The 32-bit RVA of the target.

And indeed the correct values are defined in bfd/coff-arm.c:

#ifdef ARM_WINCE
...
#define ARM_26D 0
#define ARM_32 1
#define ARM_RVA32 2
#define ARM_26 3
#define ARM_THUMB12 4
#define ARM_SECTION 14
#define ARM_SECREL 15
#endif

And for all other coff arm targets:
#define ARM_RVA32 11

But since those defines are not in a header, the pe-dll.c value
bitrotted.

This is one of those bugs that makes you hate magic constants to
the gut ;)

I have caught this while fixing --enable-runtime-pseudo-reloc for
arm-wince-pe, so I am quite sure it works correctly for that target.

The PE_ARCH_arm_epoc I am not sure, but it I guess the
reloc values should come from the PE COFF specification too.

Can anyone point me to a list of which platforms use arm-pe?
What is this epoc arm target used for?

Cheers,
Pedro Alves

---
2006-07-04 Pedro Alves <***@portugalmail.pt>

* pe-dll.c (pe_detail_list): Use correct ARM_RVA32 value for
PE_ARCH_arm, and PE_ARCH_arm_epoc cases.
Daniel Jacobowitz
2006-07-05 00:44:09 UTC
Permalink
Post by Pedro Alves
Can anyone point me to a list of which platforms use arm-pe?
What is this epoc arm target used for?
I don't know for sure, but the only EPOC I'm familiar with is the image
format used for SymbianOS. However, I'm pretty sure that the binutils
support won't work for current versions of that platform anyway. I
don't know whether anyone uses it for the older releases.
--
Daniel Jacobowitz
CodeSourcery
Pedro Alves
2006-08-08 09:58:14 UTC
Permalink
Post by Daniel Jacobowitz
Post by Pedro Alves
Can anyone point me to a list of which platforms use arm-pe?
What is this epoc arm target used for?
I don't know for sure, but the only EPOC I'm familiar with is the image
format used for SymbianOS. However, I'm pretty sure that the binutils
support won't work for current versions of that platform anyway. I
don't know whether anyone uses it for the older releases.
Thanks for the info.
So, I guess there is arm-pe, and arm-epoc-pe, both
supporting Symbian targets (different SDK versions??),
and then there is arm-wince-pe, for ARM based Windows CE devices.

[target] [bfd image format]
arm-pe pei-arm-little
arm-epoc-pe epoc-pei-arm-little
arm-wince-pe pei-arm-little

If I am correct, then problem is that arm-pe and arm-wince-pe use the
same bfd format names, but they aren't really the same.
The reloc id numbers are different, and wince doesn't use underscores
while arm-pe does, among other differences.

Should I rename wince's bfd format? wince-pei-arm-little? Then, I would
just add a new entry to pe_detail_list[] with the correct values.

Cheers,
Pedro Alves.
Pedro Alves
2006-08-08 09:59:11 UTC
Permalink
Post by Daniel Jacobowitz
Post by Pedro Alves
Can anyone point me to a list of which platforms use arm-pe?
What is this epoc arm target used for?
I don't know for sure, but the only EPOC I'm familiar with is the image
format used for SymbianOS. However, I'm pretty sure that the binutils
support won't work for current versions of that platform anyway. I
don't know whether anyone uses it for the older releases.
Thanks for the info.
So, I guess there is arm-pe, and arm-epoc-pe, both
supporting Symbian targets (different SDK versions??),
and then there is arm-wince-pe, for ARM based Windows CE devices.

[target] [bfd image format]
arm-pe pei-arm-little
arm-epoc-pe epoc-pei-arm-little
arm-wince-pe pei-arm-little

If I am correct, then problem is that arm-pe and arm-wince-pe use the
same bfd format names, but they aren't really the same.
The reloc id numbers are different, and wince doesn't use underscores
while arm-pe does, among other differences.

Should I rename wince's bfd format? wince-pei-arm-little? Then, I would
just add a new entry to pe_detail_list[] with the correct values.

Cheers,
Pedro Alves.
Nick Clifton
2006-08-08 10:04:53 UTC
Permalink
Hi Pedro,
Post by Pedro Alves
Post by Daniel Jacobowitz
Post by Pedro Alves
Can anyone point me to a list of which platforms use arm-pe?
What is this epoc arm target used for?
I don't know for sure, but the only EPOC I'm familiar with is the image
format used for SymbianOS.
The arm-epoc-pe target was for the SymbianOS. The epoc qualifier was added
to distinguish it from the WinCE targeted PE format version. Ideally arm-pe
should have been dropped, but it never was.
Post by Pedro Alves
So, I guess there is arm-pe, and arm-epoc-pe, both
supporting Symbian targets (different SDK versions??),
By now the answer is probably yes. At the time the arm-epoc-pe target
was introduced, the answer was no.
Post by Pedro Alves
[target] [bfd image format]
arm-pe pei-arm-little
arm-epoc-pe epoc-pei-arm-little
arm-wince-pe pei-arm-little
If I am correct, then problem is that arm-pe and arm-wince-pe use the
same bfd format names, but they aren't really the same.
The reloc id numbers are different, and wince doesn't use underscores
while arm-pe does, among other differences.
Should I rename wince's bfd format? wince-pei-arm-little? Then, I would
just add a new entry to pe_detail_list[] with the correct values.
Yes, this would be a very good idea.

Cheers
Nick
Pedro Alves
2006-08-09 20:40:41 UTC
Permalink
Post by Nick Clifton
Post by Pedro Alves
[target] [bfd image format]
arm-pe pei-arm-little
arm-epoc-pe epoc-pei-arm-little
arm-wince-pe pei-arm-little
If I am correct, then problem is that arm-pe and arm-wince-pe use the
same bfd format names, but they aren't really the same.
The reloc id numbers are different, and wince doesn't use underscores
while arm-pe does, among other differences.
Should I rename wince's bfd format? wince-pei-arm-little? Then, I would
just add a new entry to pe_detail_list[] with the correct values.
Yes, this would be a very good idea.
I started modeling the change after "epoc-pei-arm-little". That is,
I introduced the "wince-pei-arm-little" bfd format.
But while debugging it, I stumbled on a few things breaking. It turned
out that in some places, the bfd name is assumed to start with
"pe-" or "pei-".

ex:

bfd/libpei.h:

/* Macro: Returns true if the bfd is a PE executable as opposed to a PE
object file. */
#define bfd_pe_executable_p(abfd) \
(strncmp ((abfd)->xvec->name, "pei-", 4) == 0 \
|| strncmp ((abfd)->xvec->name, "efi-app-", 8) == 0)

These are places that easily brake with the introduction of these bfd
subformats. In fact "epoc-pei-arm-little" might be broken for this
reason. Also I saw on the archives that efi-app-* was once broken
because of this.

I don't now if there is a naming convention for these things,
and since there is at least one flavour-machine-os precedent
("elf32-shl-symbian"), I switched to "pei-arm-wince-little".

(Although not being a triplet feels weird. Maybe "pei-arml-wince" would
be better? Anyway this is probably not so important...)

(If desired, I can provide a patch to s/epoc-pei-arm-/pei-arm-epoc-/g)

Pedro Alves

---

bfd/ChangeLog

2006-08-09 Pedro Alves <***@portugalmail.pt>

* Makefile.am: Add rules to build pe-arm-wince.lo
and pei-arm-wince.lo objects.
* Makefile.in: Regenerate.

* bfd.c: ARM wince bfd format names were renamed. Adjust.
* coff-arm.c [ARM_WINCE]: Adjust so Windows CE doesn't end up
with unexpected/conflicting relocs.
* targets.c: The arm-wince-pe target has now its own new vector.
Adjust.
* config.bfd: Likewise.
* configure.in: Likewise.
* configure: Regenerate.
* pe-arm-wince.c: New file.
* pei-arm-wince.c: New file.
* pe-arm.c: Remove ARM_WINCE block.
* pei-arm.c: Likewise.

---

binutils/ChangeLog

2006-08-09 Pedro Alves <***@portugalmail.pt>

* configure.in: Split arm-pe and arm-wince-pe. Build dlltool
with -DDLLTOOL_ARM_WINCE for Windows CE case.
* configure: Regenerate.
* dlltool.c: Add support for arm-wince.

---

gas/ChangeLog

2006-08-09 Pedro Alves <***@portugalmail.pt>

* Makefile.am (TARG_ENV_HFILES): Add te-wince-pe.h.
* Makefile.in: Regenerate.
* config/tc-arm.h [TARGET_FORMAT]: ARM wince bfd names were
renamed. Adjust.

---

ld/ChangeLog

2006-08-09 Pedro Alves <***@portugalmail.pt>

* Makefile.am: Split arm-wince into its own emulation.
* Makefile.in: Regenerate.
* configure.tgt: Set targ_emul to arm_wince_pe for ARM Windows
CE targets.
* pe-dll.c [PE_ARCH_arm_wince]: Define.
(pe_detail_list): Add arm-wince case.
* emultempl/pe.em: Handle new TARGET_IS_arm_wince_pe define.
(gld_${EMULATION_NAME}_recognized_file): Handle new arm-wince
bfd format name.

---
Pedro Alves
2006-08-11 12:43:13 UTC
Permalink
Humm, just noticed the patch is not complete.
I'll work on updating it and send an updated patch later.
Sorry for the noise.

Cheers,
Pedro Alves

P.S.

I notice that arm-epoc-pe is broken in dll generation.
Was dll support disabled for it on purpose, or was it an oversight?
Nick Clifton
2006-08-11 14:02:39 UTC
Permalink
Hi Pedro,
Post by Pedro Alves
I notice that arm-epoc-pe is broken in dll generation.
Was dll support disabled for it on purpose, or was it an oversight?
It is an oversight.

Cheers
Nick
Pedro Alves
2006-08-15 17:13:12 UTC
Permalink
Hi all,
Post by Pedro Alves
Post by Nick Clifton
Post by Pedro Alves
Should I rename wince's bfd format? wince-pei-arm-little? Then, I would
just add a new entry to pe_detail_list[] with the correct values.
Yes, this would be a very good idea.
Humm, just noticed the patch is not complete.
I'll work on updating it and send an updated patch later.
I notice that arm-epoc-pe is broken in dll generation.
Here is take 2 of the same patch. It adds a few missing things I missed
on the previous patch. Additionally, it adds DLL_SUPPORT to arm-epoc-pe.
I've also removed the regenerated files from the patch. Let me know if
you need them.

Tested on arm-wince-pe, arm-pe, arm-epoc-pe and i686-pe-cygwin.

Please review and commit.

Cheers,
Pedro Alves

---

bfd/ChangeLog

2006-08-15 Pedro Alves <***@portugalmail.pt>

* Makefile.am: Add rules to build pe-arm-wince.lo
and pei-arm-wince.lo objects.
* Makefile.in: Regenerate.
* pe-arm-wince.c: New file.
* pei-arm-wince.c: New file.
* pei-arm.c: Remove ARM_WINCE block.
* pe-arm.c: Remove ARM_WINCE block. Rename
bfd_arm_pe_allocate_interworking_sections,
bfd_arm_pe_get_bfd_for_interworking, and
bfd_arm_pe_process_before_allocation to
bfd_armpe_allocate_interworking_sections,
bfd_armpe_get_bfd_for_interworking, and
bfd_armpe_process_before_allocation. Move them before
including bfd.h.
* bfd.c: ARM wince bfd format names were renamed. Adjust.
* coff-arm.c [ARM_WINCE]: Adjust so Windows CE doesn't end up
with unexpected/conflicting relocs.
* targets.c: The arm-wince-pe target got its own new vector.
Adjust.
* config.bfd: Likewise.
* configure.in: Likewise.
* configure: Regenerate.

---

binutils/ChangeLog

2006-08-15 Pedro Alves <***@portugalmail.pt>

* configure.in: Split arm-pe and arm-wince-pe. Build dlltool
with -DDLLTOOL_ARM_WINCE for Windows CE case.
* configure: Regenerate.
* dlltool.c: Add support for arm-wince.

---

gas/ChangeLog

2006-08-15 Pedro Alves <***@portugalmail.pt>

* Makefile.am (TARG_ENV_HFILES): Add te-wince-pe.h.
* Makefile.in: Regenerate.
* config/tc-arm.h [TARGET_FORMAT]: ARM wince bfd names were
renamed. Adjust.

---

ld/ChangeLog

2006-08-15 Pedro Alves <***@portugalmail.pt>

* Makefile.am: Split arm-wince into its own emulation.
* Makefile.in: Regenerate.
* configure.tgt: Set targ_emul to arm_wince_pe for ARM Windows
CE targets.
* pe-dll.c : Define PE_ARCH_arm_wince.
(pe_detail_list): Add PE_ARCH_arm_wince case.
(make_one): Handle PE_ARCH_arm_epoc and PE_ARCH_arm_wince cases.
* emulparams/arm_wince_pe.sh: New file.
* emultempl/pe.em: Handle new TARGET_IS_arm_wince_pe define.
Remap bfd_arm_allocate_interworking_sections,
bfd_arm_get_bfd_for_interworking and
bfd_arm_process_before_allocation for arm-pe and arm-wince-pe
targets too.
(gld_${EMULATION_NAME}_recognized_file): Handle arm-wince and
arm-epoc bfd format names.
Nick Clifton
2006-08-21 08:13:31 UTC
Permalink
Hi Pedro,
Post by Pedro Alves
bfd/ChangeLog
* Makefile.am: Add rules to build pe-arm-wince.lo
and pei-arm-wince.lo objects.
* Makefile.in: Regenerate.
* pe-arm-wince.c: New file.
* pei-arm-wince.c: New file.
* pei-arm.c: Remove ARM_WINCE block.
* pe-arm.c: Remove ARM_WINCE block. Rename
bfd_arm_pe_allocate_interworking_sections,
bfd_arm_pe_get_bfd_for_interworking, and
bfd_arm_pe_process_before_allocation to
bfd_armpe_allocate_interworking_sections,
bfd_armpe_get_bfd_for_interworking, and
bfd_armpe_process_before_allocation. Move them before
including bfd.h.
* bfd.c: ARM wince bfd format names were renamed. Adjust.
* coff-arm.c [ARM_WINCE]: Adjust so Windows CE doesn't end up
with unexpected/conflicting relocs.
* targets.c: The arm-wince-pe target got its own new vector.
Adjust.
* config.bfd: Likewise.
* configure.in: Likewise.
* configure: Regenerate.
---
binutils/ChangeLog
* configure.in: Split arm-pe and arm-wince-pe. Build dlltool
with -DDLLTOOL_ARM_WINCE for Windows CE case.
* configure: Regenerate.
* dlltool.c: Add support for arm-wince.
---
gas/ChangeLog
* Makefile.am (TARG_ENV_HFILES): Add te-wince-pe.h.
* Makefile.in: Regenerate.
* config/tc-arm.h [TARGET_FORMAT]: ARM wince bfd names were
renamed. Adjust.
---
ld/ChangeLog
* Makefile.am: Split arm-wince into its own emulation.
* Makefile.in: Regenerate.
* configure.tgt: Set targ_emul to arm_wince_pe for ARM Windows
CE targets.
* pe-dll.c : Define PE_ARCH_arm_wince.
(pe_detail_list): Add PE_ARCH_arm_wince case.
(make_one): Handle PE_ARCH_arm_epoc and PE_ARCH_arm_wince cases.
* emulparams/arm_wince_pe.sh: New file.
* emultempl/pe.em: Handle new TARGET_IS_arm_wince_pe define.
Remap bfd_arm_allocate_interworking_sections,
bfd_arm_get_bfd_for_interworking and
bfd_arm_process_before_allocation for arm-pe and arm-wince-pe
targets too.
(gld_${EMULATION_NAME}_recognized_file): Handle arm-wince and
arm-epoc bfd format names.
Approved and applied. Thanks for doing this!

Cheers
Nick
Pedro Alves
2006-08-21 08:53:35 UTC
Permalink
Post by Nick Clifton
Approved and applied. Thanks for doing this!
Thank you!

Cheers,
Pedro Alves
Pedro Alves
2006-08-21 22:52:03 UTC
Permalink
Post by Nick Clifton
Post by Pedro Alves
ld/ChangeLog
(...)
Post by Nick Clifton
Post by Pedro Alves
* configure.tgt: Set targ_emul to arm_wince_pe for ARM Windows
CE targets.
(...)
Post by Nick Clifton
Approved and applied. Thanks for doing this!
Looks like the above part of the patch went for a ride
into nowhere land :)

Here it goes again. Please re-review, and commit.

Cheers,
Pedro Alves

---


ld/ChangeLog

2006-08-21 Pedro Alves <***@portugalmail.pt>

* configure.tgt: Set targ_emul to arm_wince_pe for ARM
Windows CE targets.
Nick Clifton
2006-08-22 11:51:09 UTC
Permalink
Hi Pedro,
Post by Pedro Alves
Looks like the above part of the patch went for a ride
into nowhere land :)
oops!
Post by Pedro Alves
Here it goes again. Please re-review, and commit.
ld/ChangeLog
* configure.tgt: Set targ_emul to arm_wince_pe for ARM
Windows CE targets.
Approved and applied.

Cheers
Nick

Loading...