Data tables for a software tool

John S. Gwynne jsg at jsgpc.mrcday.com
Tue Sep 26 22:43:49 GMT 2000


| The data could be written as initialized C data structures.  However, I
| haven't encountered an environment where this is space and speed
| efficient.  

Could you give an example of this? I don't see how const data types
(in .rodata and .text sections) could access or be stored that differently
than data on the stack or heap.

| Also, I expect the tables to eventually be bigger than some
| environments can handle in their global data space.

I believe in linux, as an example, with kernels below 2.2 the process
limit is 2GB with that changing to something like 16GB in the soon to
be released 2.4 kernel. What environment is the limit and how big is
it? (i.e., is there really a problem here?)

| In the past, I've solved this by defining the data in an asm file and
| telling the assembler to place it in the "code" space.  The C compiler
| thinks it is referencing global data, the linker thinks the compiler is
| generating a function pointer, and it all works happily ever after.  I

I can only speak of gcc, but...

Something similar can be accomplished by compiling "const int test=10;". 
In elf, "test" will be placed in the .rodata section (in coff, I
believe the .text section). The linker script and loader will do the
right thing... this will not use heap nor data space. In the embedded
environment, these will load directly into the "code"
section. However, this is to be run under an OS with virtual
addressing right? The OS will do the right thing.

| don't know how portable this trick is.  At a minimum, the data would
| need to be written using assembler macros so that different assemblers
| could handle the same source file.  The assembler specific macros would
| translate to each asm dialect.

This doesn't sound good nor necessary... 

| Any suggestions as to how I should proceed?

Post a small example. For a limited data type, I bet we can make an
awk/sed/perl script (these are supported on most platforms I believe)
to translate your data tables into C/C++ code that will do the right thing
on all platforms.

| The data is static.  The program will never change it.
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  => const ??

| The data might eventually grow to > 64K.

Under what OS would that be a problem? 


john gwynne
----------------------------------------------------------------------------
To unsubscribe from gmecm, send "unsubscribe gmecm" (without the quotes)
in the body of a message (not the subject) to majordomo at lists.diy-efi.org




More information about the Gmecm mailing list