Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > How to group ob...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 25151 of 27670
Post > Topic >>

How to group objects from static library in a section?

by wyse03br@[EMAIL PROTECTED] Mar 27, 2008 at 10:02 AM

Hi all,

   Using GNU linker ld, I'd like to create a section .rom_code
grouping
some routines and all its dependencies, including the implicit called
ones such as math routines provided by libm.a. Going down in more
details, my intention is creating a stand-alone ROM image containing
several utility routines (with all its dependencies) that will be used
by programs loaded in RAM.
The C code is something like:


% cat test.c <<HERE
#include <stdio.h>
#include <math.h>

void _start() { main(); }

extern int main();

volatile float a, b, c;
volatile float res;

__attribute__((section(".rom_code"))) void rom_function();
void rom_function() {
  c = a / b;                // Use implicitely libm.a routine
  res = sin(c);             // Use explictly libm.a routine

}

int main() {
  rom_function();
  return 0;
}

HERE

% gcc -g test.c -lm -Wl,-T lib.lnk

   Compiling and linking in the usual way, only the rom_function()
went to ROM, not its dependencies. These are the references
to .rom_code section, only the
rom_function() routine can be found there:

% objdump -x a.out | grep rom_code
  7 .rom_code     00000070  00008000  00008000  00018000  2**2
00008000 l    d  .rom_code      00000000
00008000 g     F .rom_code      00000070 rom_function

   The sin() was placed in .text and not in .rom_code:

% objdump -x a.out | grep sin
00000000 l    df *ABS*  00000000 s_sin.c
00000000 l    df *ABS*  00000000 k_sin.c
00001438 g     F .text  000000f8 __kernel_sin
00000514 g     F .text  000000ec sin

   The linker script used is:

MEMORY
{
        RAM_CODE : o = 0x0000 , l = 0x8000
        ROM_CODE : o = 0x8000 , l = 0x8000

}

SECTIONS
{
        .bss            : { *(.bss) }                   > RAM_CODE
        .sbss           : { *(.sbss) }                  > RAM_CODE
        .rodata         : { *(.rodata*) }               > RAM_CODE
        .got2           : { *(.got*) }                  > RAM_CODE
        .data           : { *(.data) }                  > RAM_CODE
        .sdata          : { *(.sdata*) }                > RAM_CODE

        .text           : { *(.text .text.*) }  > RAM_CODE

        .rom_code       : { *(.rom_code) }              > ROM_CODE

}

   Any ideas on how to put also the rom_function() dependencies into
ROM?

   Tks

               Walter
 




 5 Posts in Topic:
How to group objects from static library in a section?
wyse03br@[EMAIL PROTECTED  2008-03-27 10:02:17 
Re: How to group objects from static library in a section?
jacob navia <jacob@[EM  2008-03-27 18:14:16 
Re: How to group objects from static library in a section?
wyse03br@[EMAIL PROTECTED  2008-03-27 12:46:03 
Re: How to group objects from static library in a section?
jacob navia <jacob@[EM  2008-03-27 21:18:30 
Re: How to group objects from static library in a section?
Jack Klein <jackklein@  2008-03-27 16:03:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 22:12:01 CDT 2008.