public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* HELP with linker script!!!
@ 2005-03-31 14:42 Pieter Arnout
  2005-03-31 15:50 ` Nick Clifton
  0 siblings, 1 reply; 14+ messages in thread
From: Pieter Arnout @ 2005-03-31 14:42 UTC (permalink / raw)
  To: binutils

I read the the Red Hat manual "Using ld, the GNU Linker", but I'm 
having trouble. Essentially, I'd like to take specific symbols and 
assign them to a memory region, rather than just take a section and 
assign it to a memory region. I can obtain the symbol values and symbol 
type from the objdump or nm output. The only examples offered in the 
manual, however, only define the output sections .bss and .data by just 
assigning everything from the .bss and .data input sections to it:

SECTIONS
{
	. = 0x10000;
	.text : { *(.text) }
	. = 0x8000000;
	.data : { *(.data) }
	.bss : { *(.bss) }
}

I want some finer control. Does anyone know how I can go about 
ultimately assigning specific symbols (or data structures if you will) 
to a memory region? Should / can I create a section (much like .text, 
.data or .bss above) in the linker script and call it "my_section" and 
assign a list of symbols to "my_section"? Is this how I would go about 
accomplishing what I want? If so do I reference the symbols by name or 
by value when I call them out in the SECTIONS command? How does that 
look like?

Additionally, where do I define the start and end regions of my stack 
and heap? I use .bss for uninitialized variables, .data for initialized 
variables, but how do I reference the beginning and end of stack and 
the beginning and end of heap?

I need answers urgently.

Thanks so much for your help!

Pieter

^ permalink raw reply	[flat|nested] 14+ messages in thread
* RE: HELP with linker script!!!
@ 2005-03-31 15:08 Zagorodnev, Grigory
  0 siblings, 0 replies; 14+ messages in thread
From: Zagorodnev, Grigory @ 2005-03-31 15:08 UTC (permalink / raw)
  To: Pieter Arnout, binutils

Hi, Pieter!
You may consider this example: "implicit" linker script contains extra
information to combine user-defined section with default ".data" one,
providing the beginning mark. C program accesses this mark as data
object. 

$ cat main.c
#include <stdio.h>

int my_val __attribute__((section("my_section"))) = 123;
 
extern int my_section_start;
 
int main(){
    printf("%d - %d\n", my_val, my_section_start);
}

$ cat main.script 
SECTIONS
{
    .data : { 
        my_section_start = .;
        *(my_section) 
    }
}

$ gcc main.c main.script 
$ ./a.out

123 - 123


Best regards!
---
Grigory Zagorodnev
Intel Corporation

>-----Original Message-----
>From: binutils-owner@sources.redhat.com [mailto:binutils-
>owner@sources.redhat.com] On Behalf Of Pieter Arnout
>Sent: Thursday, March 31, 2005 4:27 AM
>To: binutils@sources.redhat.com
>Subject: HELP with linker script!!!
>
>I read the the Red Hat manual "Using ld, the GNU Linker", but I'm
>having trouble. Essentially, I'd like to take specific symbols and
>assign them to a memory region, rather than just take a section and
>assign it to a memory region. I can obtain the symbol values and symbol
>type from the objdump or nm output. The only examples offered in the
>manual, however, only define the output sections .bss and .data by just
>assigning everything from the .bss and .data input sections to it:
>
>SECTIONS
>{
>	. = 0x10000;
>	.text : { *(.text) }
>	. = 0x8000000;
>	.data : { *(.data) }
>	.bss : { *(.bss) }
>}
>
>I want some finer control. Does anyone know how I can go about
>ultimately assigning specific symbols (or data structures if you will)
>to a memory region? Should / can I create a section (much like .text,
>.data or .bss above) in the linker script and call it "my_section" and
>assign a list of symbols to "my_section"? Is this how I would go about
>accomplishing what I want? If so do I reference the symbols by name or
>by value when I call them out in the SECTIONS command? How does that
>look like?
>
>Additionally, where do I define the start and end regions of my stack
>and heap? I use .bss for uninitialized variables, .data for initialized
>variables, but how do I reference the beginning and end of stack and
>the beginning and end of heap?
>
>I need answers urgently.
>
>Thanks so much for your help!
>
>Pieter

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-04-04 13:39 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-31 14:42 HELP with linker script!!! Pieter Arnout
2005-03-31 15:50 ` Nick Clifton
     [not found]   ` <29c1ff0410ff9cc2b88a3ad82d1938aa@powerescape.com>
2005-04-01 11:27     ` Nick Clifton
2005-04-01 12:53       ` Vincent Rubiolo
2005-04-01 14:05         ` Nick Clifton
2005-04-01 14:13           ` Dave Korn
2005-04-01 14:34             ` Andreas Schwab
2005-04-01 16:53       ` Pieter Arnout
2005-04-04  9:39         ` Vincent Rubiolo
2005-04-04 11:06         ` Nick Clifton
2005-04-04 11:11           ` Dave Korn
2005-04-04 11:59           ` Sergei Organov
2005-04-04 13:39             ` Nick Clifton
2005-03-31 15:08 Zagorodnev, Grigory

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).