The Lab Book Pages

An online collection of electronics information

http://www.labbookpages.co.uk

Dr. Andrew Greensted
Last modified: 18th November 2009

Hide Menu


Valid XHTML Valid CSS
Valid RSS VIM Powered
RSS Feed Icon

This site uses Google Analytics to track visits. Privacy Statement

Page Icon

Code Segments

A few bits of information on code segments and linking.

Note: This HowTo uses Xilinx EDK version 9.1i


Code Segments

Below is a list of some of the code segments that GCC can produce with descriptions of their purpose.

SegmentsDescription
.textProgram code
.dataInitialised global data
.sdataSmall .data
.bssUninitialised global data (Block Starting Symbol)
.sbssSmall .bss
.rodataConstants (Read only data)
.sdata2Small read only data

Below is an example taken from the Xilinx application note xapp642. It shows how different variables relate to code segments.

File: example.c
#include <stdio.h>
 
int array_data[10] = {0,1,2,3,4,5,6,7,8,9};
⇐ .data
const int array_const[10] = {9,8,7,6,5,4,3,2,1,0};
⇐ .rodata
 
int main(void)
{
   int i;
⇐ .bss
   i = i + 10;
⇐ .text
   printf("%d\n", array_data[0]);
⇐ .text
   array_data[0] = array_const[0];
⇐ .text
   printf("%d\n",array_data[0]);
⇐ .text
 
   return 0;
}

Further Reading

Suggestions for further reading.


Book Logo