[U-Boot-Users] Are gnu liker scripts available for C files?

Grant Likely grant.likely at secretlab.ca
Mon May 8 05:46:50 CEST 2006


On 5/7/06, Forrest Chan <chenm at scut.edu.cn> wrote:
> Hello guys,
> I know, to implement XIP(eXecute In Place) on linux, read-only data and read-writable data of linux have to be splitted by some certain means, say, by way of using gnu linker scripts. Yes, gnu linker scripts are available to assemble language, but what about C files? Can the scritps separate the two types of data in C files? You know, C source files don't have diretives, like "AREA", "DATA" and "CODE", as assemble source files do.
> Any reply is appreciated.

This question is a little off-topic for this list.

Typically; the C compiler uses the following sections:

machine code in .text
initialized globals and statics in .data*
uninitialized globals and statics in .bss (which init code is supposed
to clear with zeros)
constants in .rodata*

You can use a regular linker script to put those sections where you want them.

use the gnu 'readelf' tool to see what sections are in a compiled .o
file.  I think you need to look at your targets ABI documentation to
figure out which sections you should be handling:

$ powerpc-linux-readelf -e ml403.o
ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           PowerPC
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          2456 (bytes into file)
  Flags:                             0x8000, relocatable-lib
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         25
  Section header string table index: 22

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        00000000 000034 000144 00  AX  0   0  4
  [ 2] .rela.text        RELA            00000000 000f58 000060 0c     23   1  4
  [ 3] .data             PROGBITS        00000000 000178 000000 00  WA  0   0  1
  [ 4] .bss              NOBITS          00000000 000178 000000 00  WA  0   0  1
  [ 5] .debug_abbrev     PROGBITS        00000000 000178 0000ed 00      0   0  1
  [ 6] .debug_info       PROGBITS        00000000 000265 000261 00      0   0  1
  [ 7] .rela.debug_info  RELA            00000000 000fb8 00027c 0c     23   6  4
  [ 8] .debug_line       PROGBITS        00000000 0004c6 00009d 00      0   0  1
  [ 9] .rela.debug_line  RELA            00000000 001234 00000c 0c     23   8  4
  [10] .got2             PROGBITS        00000000 000563 000010 00  WA  0   0  1
  [11] .rela.got2        RELA            00000000 001240 000030 0c     23  10  4
  [12] .rodata.str1.4    PROGBITS        00000000 000574 000050 01 AMS  0   0  4
  [13] .debug_frame      PROGBITS        00000000 0005c4 000088 00      0   0  4
  [14] .rela.debug_frame RELA            00000000 001270 000078 0c     23  13  4
  [15] .debug_pubnames   PROGBITS        00000000 00064c 00005f 00      0   0  1
  [16] .rela.debug_pubna RELA            00000000 0012e8 00000c 0c     23  15  4
  [17] .debug_aranges    PROGBITS        00000000 0006ab 000020 00      0   0  1
  [18] .rela.debug_arang RELA            00000000 0012f4 000018 0c     23  17  4
  [19] .debug_str        PROGBITS        00000000 0006cb 0001e1 01  MS  0   0  1
  [20] .note.GNU-stack   PROGBITS        00000000 0008ac 000000 00      0   0  1
  [21] .comment          PROGBITS        00000000 0008ac 000012 00      0   0  1
  [22] .shstrtab         STRTAB          00000000 0008be 0000da 00      0   0  1
  [23] .symtab           SYMTAB          00000000 000d80 000180 10     24  16  4
  [24] .strtab           STRTAB          00000000 000f00 000057 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no program headers in this file.

--
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
(403) 399-0195




More information about the U-Boot mailing list