This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
bug fix for displaying load address in the map file
- From: "Ina Pandit" <InaP at KPITCummins dot com>
- To: <binutils at sources dot redhat dot com>
- Cc: "Ina Pandit" <InaP at KPITCummins dot com>
- Date: Fri, 8 Dec 2006 17:49:58 +0530
- Subject: bug fix for displaying load address in the map file
Hi,
I downloaded the latest snapshot of binutils (20061206) and found the
following problem in it.
The "load address" of a section is not displayed in the map file when it is
assigned using 'AT > lma_region' expression in the linker script i.e.
.data {*(.data) } >ram AT>rom
However, if the load address is assigned using AT(lma) expression
in the linker script, i.e.
.data : AT(lma) {*(.data)} >ram
it is displayed in the map file.
The function "print_output_section_statement" (in ldlang.c), prints
the load address in the map file if "load_base" is not NULL. To solve
this problem, I modified the function "lang_size_sections_1" (in ldlang.c).
However, after this modification, the linker function LOADADDR(section),
computed incorrect value of LMA of a section. The value computed was
the sum of LMA and VMA.
For this, I modified the function "fold_name" (in ldexp.c).
This fixed the problem.
The previous test case was not checking the values of the load addresses
in the generated map file. The necessary changes have been made in the
test case for the same.
Please find the patch below:
ChangeLog:
2006-12-08 Ina Pandit <inap@kpitcummins.com>
ld/
* ldexp.c (fold_name <LOADADDR>): Load addresses of sections with an
lma_region are absolute.
* ldlang.c (lang_size_sections_1): Set load_base
ld/testsuite/
* ld-scripts/overlay-size-map.d: Update.
======================================================================
--- binutils-061206/ld/ldlang.c.orig 2006-10-31 04:55:51.000000000 +0530
+++ binutils-061206/ld/ldlang.c 2006-12-07 18:44:59.000000000 +0530
@@ -4505,6 +4505,9 @@ lang_size_sections_1
if (os->lma_region != NULL && os->lma_region != os->region)
{
+ /* Set load_base */
+ os->load_base = exp_intop (os->lma_region->current);
+
os->lma_region->current
= os->bfd_section->lma + TO_ADDR (os->bfd_section->size);
--- binutils-061206/ld/ldexp.c.orig 2006-08-23 07:05:31.000000000 +0530
+++ binutils-061206/ld/ldexp.c 2006-12-07 18:44:59.000000000 +0530
@@ -579,7 +579,14 @@ fold_name (etree_type *tree)
if (os->load_base == NULL)
new_abs (os->bfd_section->lma);
else
+ {
exp_fold_tree_1 (os->load_base);
+
+ /* If this section has a load region, the expression
+ will be absolute. */
+ if (os->lma_region && expld.result.valid_p)
+ expld.result.section = bfd_abs_section_ptr;
+ }
}
}
break;
--- binutils-061206/ld/testsuite/ld-scripts/overlay-size-map.d.orig 2006-08-16 14:01:45.000000000 +0530
+++ binutils-061206/ld/testsuite/ld-scripts/overlay-size-map.d 2006-12-07 18:44:59.000000000 +0530
@@ -5,19 +5,19 @@
#...
\.bss3 *0x0*20000 *0x20
#...
-\.mtext *0x0*10000 *0x20
+\.mtext *0x0*10000 *0x20 load address 0x0*30000
#...
\.mbss *0x0*20030 *0x230 load address 0x0*20060
#...
-\.text1 *0x0*10020 *0x80
+\.text1 *0x0*10020 *0x80 load address 0x0*30020
#...
-\.text2 *0x0*10020 *0x40
+\.text2 *0x0*10020 *0x40 load address 0x0*300a0
#...
-\.text3 *0x0*10020 *0x20
+\.text3 *0x0*10020 *0x20 load address 0x0*300e0
#...
-\.data1 *0x0*20260 *0x30
+\.data1 *0x0*20260 *0x30 load address 0x0*30100
#...
-\.data2 *0x0*20260 *0x40
+\.data2 *0x0*20260 *0x40 load address 0x0*30130
#...
-\.data3 *0x0*20260 *0x50
+\.data3 *0x0*20260 *0x50 load address 0x0*30170
#pass
======================================================================
Please let me know if the patch is OK.
?
Regards,
Ina Pandit
KPIT Cummins InfoSystems Ltd.
Pune, India
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH, H8, R8C, M16C
and M32C Series. The following site also offers free technical support
to its users. Visit http://www.kpitgnutools.com for details.
Latest versions of KPIT GNU tools were released on October 3, 2006.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~