This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH]: Fix ld bug triggered in arm-*-pe (?)
- From: Pedro Alves <pedro_alves at portugalmail dot pt>
- To: binutils at sourceware dot org
- Date: Mon, 14 Aug 2006 23:52:04 +0100
- Subject: [PATCH]: Fix ld bug triggered in arm-*-pe (?)
Hi all,
While doing the arm-pe/arm-wince-pe split, I noticed that
the ld/ld-scripts/script.exp [script] test would fail for arm-wince-pe
but not for arm-epoc-pe.
Here is the script.t file for reference (with minor editing for better
mail reading):
SECTIONS
{
.text 0x100 : { text_start = .; *(.text) *(.pr) text_end = .; }
. = 0x1000;
.data : { data_start = .; *(.data) *(.rw) data_end = .; }
}
Without the attached patch, I am getting a data_start == 0x00000104,
that is, the dot assignment
is being lost.
nm output:
U .bss
00000104 d .data
00000100 t .text
(...)
I traced it to the fact that the default section alignment for
arm-wince-pe/arm-pe is 0x1000
while for arm-epoc-pe it is 0x400.
If I change 0x1000 to something else, say 0x1010, and retest in
arm-wince-pe,
the dot assign is *not* ignored. If I change the 0x1000 to 0x400 and
test with arm-epoc-pe,
I get the same bug.
I tried reproducing with i686-pc-cygwin, but I couldn't.
This may have something to do with the ".glue_7*" sections not being
present there.
The attached patch fixes the problem, but I am not sure if I'm not fixing
the symptom instead.
Tested on arm-pe, arm-wince-pe, arm-epoc-pe and i686-pc-cygwin for
regressions.
Cheers,
Pedro Alves
---
ld/ChangeLog
2006-08-14 Pedro Alves <pedro_alves@portugalmail.pt>
* ldlang.c (lang_size_sections_1, lang_assignment_statement_enum):
Adjust the current address of DEFAULT_MEMORY_REGION even
when dot hasn't changed.
Index: ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.233
diff -u -p -r1.233 ldlang.c
--- ldlang.c 8 Aug 2006 16:08:47 -0000 1.233
+++ ldlang.c 14 Aug 2006 20:34:28 -0000
@@ -4535,7 +4535,7 @@ lang_size_sections_1
output_section_statement->bfd_section,
&newdot);
- if (newdot != dot && !output_section_statement->ignored)
+ if (!output_section_statement->ignored)
{
if (output_section_statement == abs_output_section)
{
@@ -4544,8 +4544,8 @@ lang_size_sections_1
lang_memory_region_lookup (DEFAULT_MEMORY_REGION,
FALSE)->current = newdot;
}
- else
- {
+ else if (newdot != dot)
+ {
/* Insert a pad after this statement. We can't
put the pad before when relaxing, in case the
assignment references dot. */