ld: Simple Linker Script Example

Barry Rountree rountree@uga.edu
Fri Nov 7 04:41:00 GMT 2003
On Thursday 06 November 2003 11:20 pm, Ian Lance Taylor wrote:
> Barry Rountree <rountree@uga.edu> writes:
> > Program Headers:
> >   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
> >   PHDR           0x000034 0x00001034 0x00000000 0x00120 0x00120 R E 0x4
>
> The program headers are not in a loadable segment, although I don't
> think that should be a problem.  To get them into a loadable segment,
> put *(.interp) before your .sandbox_* sections.
>
> I can't see any other reason for this to fail.  As you say, it's
> probably something obvious.
>

Yep, that did it.  Wow.  Many, many thanks for the help!

The diff is pretty much as you'd expect:

--- script.ld.orig      2003-11-06 22:45:57.000000000 -0500
+++ script.ld   2003-11-06 23:31:42.000000000 -0500
@@ -9,8 +9,25 @@
 SECTIONS
 {
   /* Read-only sections, merged into text segment: */
-  . = 0x08048000 + SIZEOF_HEADERS;
+  . = 0x08048000 + 0x200;
   .interp         : { *(.interp) }
+
+  . += 0x1000;
+  . = ALIGN(0x1000);
+
+  .sandbox_text   : { ext.o ( .text ) }
+  . += 0x1000;
+  . = ALIGN(0x1000);
+
+  .sandbox_data   : { ext.o ( .data ) }
+  . += 0x1000;
+  . = ALIGN(0x1000);
+
+  .sandbox_bss   : { ext.o ( .bss  ) }
+  . += 0x1000;
+  . = ALIGN(0x1000);
+
+
   .hash           : { *(.hash) }
   .dynsym         : { *(.dynsym) }
   .dynstr         : { *(.dynstr) }


> Ian

Barry



More information about the Binutils mailing list