This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more infromation.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
How can I access information about a section from within my C or assembly code? Specifically, I need to know the starting address and size (or ending address) of a section. Now, I already know how to do this as a C-language variable, but I think I need access to these values as literals. Hold on a sec and I'll show why... Here is an excerpt from my linker script: __________________________________________________________________ .my_tables : { __tables_start = .; *(.my_tables) __tables_end = .; __tables_size = __tables_end - __tables_start; } > rom __________________________________________________________________ And here is some assembly code (inside a C file): __________________________________________________________________ __asm__( " .extern __tables_size\n" "DATA_Table:\n" " DC.B 0x01\n" /* UBYTE table format version */ " DC.B 0x00\n" /* UBYTE unused_a for alignment */ " DC.L __tables_size\n" ) __________________________________________________________________ Note that the linker would have to put the final (literal) value of "__tables_size" directly at this location at link time. I can't really use a variable to refer to "__tables_size" and copy the value to this location at run time (at least not easily). The above code generates an error in the assembler: "Error: undefined symbol __tables_size in operation". It is possible to do this with MRI (I am converting from MRI to GNU), so I really hope GNU has an easy way to do this as well. I've looked through some of the documentation but not thoroughly. If you can point me to the right part of the documentation please do. I *really* don't want to use MRI-compatibility mode. I've already gotten most of it converted to GNU and would like to move totally from the old syntax. If GNU simply cannot do some of the nice things that MRI can do, then I'll be sorely disappointed. Here is the corresponding MRI-compatible assembly code: __________________________________________________________________ #pragma asm XDEF _DATA_Table _DATA_Table: DC.B $01 /* UBYTE table format version */ DC.B $00 /* UBYTE unused_a for alignment */ DC.L .SIZEOF.(.my_tables) #pragma endasm __________________________________________________________________ As you can see with MRI it is easy. I can have the linker just stick the size of the ".my_tables" section directly at the desired location, using the ".SIZEOF." directive. MRI also has a ".STARTOF." directive for obtaining the start address of a section. Can anyone help? (Thanks to those that helped me with other stuff... almost there now.) Chris
begin:vcard n:Bahns;Christopher tel;home:812-342-4714 tel;work:812-342-4714 x-mozilla-html:FALSE adr:;;;;;; version:2.1 email;internet:chris@bahns.com fn:Christopher Bahns end:vcard
------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |