How to make section take no space in output file?

Rick Mann
Mon Jan 14 08:46:00 GMT 2008

I'm building an embedded target binary that has a couple of large data  
structures (frame buffers and MMU tables). In the C code they're  
represented as arrays, and they're assigned to their own sections,  
which the linker script ensures are properly aligned. Two problems  
arise: the alignment introduces very large gaps in the file (corrected  
with the AT linker script directive), and they are large themselves  
(each framebuffer structure is nearly a megabyte in size).

As you can imagine, this makes downloads to the target time consuming.

I can (rather clumsily) deal with the alignment issue (the  
aforementioned AT), but how do I keep the sections from taking up any  
space? I could even make them overlap, but the largest one will still  
use up space. Since these have no data that needs to be written to the  
output file, it seems like there'd be an easy way to just say "this  
section shouldn't take up space in the file, and neither should the  
sections that follow".

If I understand ld correctly, this is how the .bss section behaves. It  
consumes no space in the resulting output file. How does the linker  
know to do this for .bss, and how do I get it to treat my other  
sections similarly?

Thanks very much!


More information about the Binutils mailing list