2011-10-21 06:19:16     defsym for resolving function address

Document created by Aaronwu Employee on Oct 16, 2013
Version 1Show Document
  • View in full screen mode

2011-10-21 06:19:16     defsym for resolving function address

Prasanth Rajagopal (INDIA)

Message: 104073   

 

I am working on the 2010R1 release in Windows/Bare Metal.

 

I need to resolve a function address directly, like the RESOLVE(sym, addr) in VDSP. I have been trying with :

 

-Wl,--defsym -Wl,__return_from_booting=0xffa04000

 

and

 

-Wl,--defsym,__return_from_booting=0xffa04000

 

But I could not resolve the address at all, the mapping is just happening normal from my linker script. I don't see any errors.  My code is in ASM, but I dont see difference in C too.

 

>>>>>>>>>>>>>>>>>Log out

 

**** Build of configuration Debug for project bfrom_check ****

 

 

 

make all

 

'Building file: ../src/process_func.s'

 

'Invoking: Blackfin ELF C Compiler'

 

bfin-elf-gcc -O0 -g3 -Wall -c -fmessage-length=0 -mcpu=bf527-any -MMD -MP -MF"src/process_func.d" -MT"src/process_func.d" -o"src/process_func.o" "../src/process_func.s"

 

'Finished building: ../src/process_func.s'

 

' '

 

'Building target: bfrom_check'

 

'Invoking: Blackfin ELF C Linker'

 

bfin-elf-gcc -T ldscript.ld -Wl,--defsym -Wl,__return_from_booting=0xffa04000 -Wl,-Map=Linker.map -v -mcpu=bf527-any -o"bfrom_check" ./src/bfrom_check.o ./src/process_func.o ./src/sdram_load.o

 

Using built-in specs.

 

Target: bfin-elf

 

Configured with: /usr/local/src/blackfin/git/toolchain/gcc-4.3/configure --build=i686-pc-linux-gnu --host=i586-mingw32msvc --target=bfin-elf --prefix=/usr/local/src/blackfin/toolchains/win32/20101128/bfin-elf --with-newlib --disable-libstdcxx-pch --enable-languages=c,c++ --disable-symvers --disable-libssp --disable-libffi --enable-clocale=generic --enable-version-specific-runtime-libs --enable-__cxa_atexit --with-bugurl=URL:http://blackfin.uclinux.org/gf/project/toolchain/tracker --with-pkgversion=ADI-trunk/git-613986c

 

Thread model: single

 

gcc version 4.3.5 (ADI-trunk/git-613986c)

 

COMPILER_PATH=c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../libexec/gcc/bfin-elf/4.3.5/;c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../libexec/gcc/;c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/../../../../bfin-elf/bin/

 

GNU ld version 2.17

 

Supported emulations:

 

elf32bfin

 

elf32bfinfd

 

'Finished building target: bfrom_check'

 

' '

 

LIBRARY_PATH=c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/;c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/;c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/../../../../bfin-elf/lib/

 

COLLECT_GCC_OPTIONS='-T' 'ldscript.ld' '-v' '-mcpu=bf527-any' '-obfrom_check'

 

c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../libexec/gcc/bfin-elf/4.3.5/collect2.exe -V -Qy -init __init -fini __fini -obfrom_check c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/../../../../bfin-elf/lib/basiccrt.o c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/crti.o c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/crtbegin.o c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/crtlibid.o -Lc:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5 -Lc:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc -Lc:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/../../../../bfin-elf/lib --defsym __return_from_booting=0xffa04000 -Map=Linker.map ./src/bfrom_check.o ./src/process_func.o ./src/sdram_load.o -lgcc --start-group -lc -lnosys --end-group -lgcc c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/crtend.o c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/crtn.o -T ldscript.ld

 

 

' '>>>>>>>>>>>>>>>>>>>>>ASM code

 

.text;

 

.align 4;

 

.global _return_from_booting;

 

__return_from_booting:

 

RTS;

 

>>>>>>>>>>>>>>>>>>>>>>>> MAP file

 

LOAD c:/program files/analog devices/gnu toolchain/svn-20101128/elf/bin/../lib/gcc/bfin-elf/4.3.5/crtlibid.o

 

0xffa04000 __return_from_booting = 0xffa04000

QuoteReplyEditDelete

 

 

2011-10-21 11:14:03     Re: defsym for resolving function address

Stuart Henderson (UNITED KINGDOM)

Message: 104081   

 

Hi Prasanth,

 

To my knowledge there is no direct GNU equivilent for VisualDSP's RESOLVE command.  I believe defsym only defines a symbol at that address, it doesn't actually move the function there.

 

In general it is discouraged to place/reference functions at absolute addresses, as the linker will almost always do a better job than you.  However, if you really think you have to, then I would recommend creating a new section in your linker script at the address you want to place the code and then use a function attribute to place your function into this new section.

 

Information on creating a new section can be found here:

http://sourceware.org/binutils/docs/ld/Scripts.html#Scripts

 

and information on using the "section" function attribute can be found here:

http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

 

Stu

QuoteReplyEditDelete

 

 

2011-10-21 12:25:38     Re: defsym for resolving function address

Prasanth Rajagopal (INDIA)

Message: 104082   

 

Hi Stuart,

 

Thanks for the point.

 

I am trying to create a new section for my assembly code:

 

MEM_L1_CODE_CACHE : ORIGIN = 0xFFA04000, LENGTH = 0xC000

 

.textspecial :

{

*(.textspecial .textspecial.*)

} >MEM_L1_CODE_CACHE

 

Although the linker is mapping:

 

.textspecial 0xffa04000 0x28

      *(.textspecial .textspecial.*)

      .textspecial 0xffa04000 0x28 ./src/process_func.o

      0xffa04000 return_from_booting

 

The code is not really taken in to the address from 0xffa04000 from my *.s assembly code. I see that linker can jump to the variable return_from_booting at address 0xffa04000, but the contents are different in those locations. I have used C attributes before, so maybe I am doing some obvious mistake:

 

.section .textspecial #“x”;

.align 4;

.global _return_from_booting;

_return_from_booting:

 

P0.L = sp_val;

P0.H = sp_val;

R0 = [P0];

SP = R0;

 

P0.L = fp_val;

P0.H = fp_val;

R0 = [P0];

FP = R0;

 

P0.L = rets_val;

P0.H = rets_val;

R0 = [P0];

RETS = R0;

 

RTS;

QuoteReplyEditDelete

 

 

2011-10-24 05:26:51     Re: defsym for resolving function address

Stuart Henderson (UNITED KINGDOM)

Message: 104132   

 

Hi Prasanth,

 

I would recommend compiling a C example with a section attribute (e.g. int func (int c) __attribute__ ((section (".textspecial"))); ) and -save-temps and then comparing the generated assembly with what you are using.  For instance, i'm getting the following section attributes:

 

    .section    .specialtext,"ax",@progbits

    .align 4

.global _func;

.type _func, STT_FUNC;

_func:

 

and when I load the binary to hardware the assembly looks the same.

 

Stu

Attachments

    Outcomes