LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2013, 10:33 PM   #1
phoenix@guru
LQ Newbie
 
Registered: Sep 2011
Location: China
Distribution: Debian
Posts: 5

Rep: Reputation: 0
Question how to access base address and size of .text, .data, .bss segments using GNU as


hi, all

i'm working on s3c2410 based development platform now and want to get base address and size of .text, .data, .bss segments in assembly language using GNU as, but when i linked the source code using "arm-linux-gcc -T lnk.lds", it told me:

""""""
make all
arm-linux-gcc -T lnk.lds -o testLeds.elf 2410init.o 2410IIC.o 2410lib.o 2410slib.o 2410swis.o main.o mmu.o
collect2: ld terminated with signal 11 [Segmentation fault]
/home/phoenixcyan/workspace/opt/openjtag/gcc-3.4.5-glibc-2.3.6/bin/../lib/gcc/arm-linux/3.4.5/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oST)(.text+0x5c): In function `__libc_csu_init':
: undefined reference to `__init_array_end'
/home/phoenixcyan/workspace/opt/openjtag/gcc-3.4.5-glibc-2.3.6/bin/../lib/gcc/arm-linux/3.4.5/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oST)(.text+0x60): In function `__libc_csu_init':
: undefined reference to `__init_array_start'
/home/phoenixcyan/workspace/opt/openjtag/gcc-3.4.5-glibc-2.3.6/bin/../lib/gcc/arm-linux/3.4.5/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oST)(.text+0xbc): In function `__libc_csu_fini':
: undefined reference to `__fini_array_end'
/home/phoenixcyan/workspace/opt/openjtag/gcc-3.4.5-glibc-2.3.6/bin/../lib/gcc/arm-linux/3.4.5/../../../../arm-linux/lib/libc_nonshared.a(elf-init.oST)(.text+0xc0): In function `__libc_csu_fini':
: undefined reference to `__fini_array_start'
/home/phoenixcyan/workspace/opt/openjtag/gcc-3.4.5-glibc-2.3.6/bin/../lib/gcc/arm-linux/3.4.5/../../../../arm-linux/bin/ld: BFD 2.15 assertion fail /work/tools/create_crosstools/crosstool-0.43/build/arm-linux/gcc-3.4.5-glibc-2.3.6/binutils-2.15/bfd/elf32-arm.h:3905
make: *** [all] Error 1
""""""

the contents of lnk.lds are:

""""""
SECTIONS {
. = 0x00;
_text = .;
.text : { *(.text) }
_etext = .;
.rodata ALIGN(4) : {*(.rodata)}
_data = .;
.data ALIGN(4) : { *(.data) }
_edata = .;
_bstart = .;
.bss ALIGN(4) : { *(.bss) *(COMMON) }
_bend = .;
}
""""""

then i compile it without specifying "-T lnk.lds", it showed:

""""""
make all
arm-linux-gcc -o testLeds.elf 2410init.o 2410IIC.o 2410lib.o 2410slib.o 2410swis.o main.o mmu.o
2410init.o(.text+0x320):/home/phoenixcyan/workspace/microembed/samsung/work/eclipse_projects/testMotorC/2410init.s:341: undefined reference to `_data'
2410init.o(.text+0x324):/home/phoenixcyan/workspace/microembed/samsung/work/eclipse_projects/testMotorC/2410init.s:341: undefined reference to `_bstart'
2410init.o(.text+0x328):/home/phoenixcyan/workspace/microembed/samsung/work/eclipse_projects/testMotorC/2410init.s:341: undefined reference to `_bend'
2410lib.o(.data+0x0): In function `Delay':
/home/phoenixcyan/workspace/microembed/samsung/work/eclipse_projects/testMotorC/2410lib.c:21: undefined reference to `_data'
collect2: ld returned 1 exit status
make: *** [all] Error 1
""""""

as i wrote assembly code in file 2410init.s below:

""""""
.extern _text @ Base of .text
.extern _etext @ End of .text
.extern _data @ Base of .data
.extern _edata @ End of .data
.extern _bstart @ Base of .bss
.extern _bend @ End of .bss
""""""

maybe the _text, _data, _bstart are not defined internally, then i want to know how to access base address and size of .text, .data, .bss segments in assembly code, or other methods ?

thanks.

Last edited by phoenix@guru; 04-20-2013 at 10:36 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Address Space Randomization on 2.6.28-15-generic ubuntu 9.04. Finding base address nullprocess Linux - Security 1 09-15-2009 12:56 AM
Address Space Randomization on 2.6.28-15-generic ubuntu 9.04. Finding base address nullprocess Linux - Kernel 1 09-14-2009 08:31 PM
Address Space Randomization on 2.6.28-15-generic ubuntu 9.04. Finding base address nullprocess Linux - Kernel 0 09-14-2009 10:45 AM
total size of segments reported by Readelf/Objdump doesn't match symbol table sizes quartermaster Linux - Software 1 08-11-2006 01:31 PM
Unable to Access urpmi data base dolphans1 Mandriva 4 07-08-2005 04:55 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration