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