Hi,
I am using a recent stable release of binutils to compile u-boot for MIPS.
The loader version is "GNU ld (GNU Binutils) 2.26.20160125".
When compiling one of the u-boot demo applications using the "-Ttext
0x80200000" option, the resulting elf file has a .MIPS.abiflags section with
a load address of "004000b8". The problem is the loader is not honouring the
-Ttext flag for the .MIPS.abiflags section like it does for the .got,
.rodata and .bss sections. I have included the readelf output below.
The resulting ELF file is problematic because a load address of "00400b8"
may not be what you want. As a work-around, I have modified u-boot to ignore
sections with a type of MIPS_ABIFLAGS. Traditionally, the basic u-boot ELF
loader has read in any sections with the "Allocation" flag set. In this way,
it does not need to know anything about the sections it is loading as long
as the load addresses are reasonable.
This problem also affects the program headers. I tried to devise a solution
in the binutils ld code but with all of the magic going on, I just couldn't.
Thanks for all of your hard work and contributions.
Best,
Geoff Mottram
The complete output from "readelf -a" is:
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: EXEC (Executable file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x80200910
Start of program headers: 52 (bytes into file)
Start of section headers: 170884 (bytes into file)
Flags: 0x70001007, noreorder, pic, cpic, o32,
mips32r2
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 4
Size of section headers: 40 (bytes)
Number of section headers: 20
Section header string table index: 17
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 80200000 010000 002e98 00 AX 0
0 16
[ 2] .MIPS.abiflags MIPS_ABIFLAGS 004000b8 0000b8 000018 18 A 0
0 8
[ 3] .rodata PROGBITS 80202e98 012e98 001244 00 A 0
0 4
[ 4] .got PROGBITS 802140e0 0140e0 000100 04 WAp 0
0 16
[ 5] .bss NOBITS 802141e0 0141e0 0009c8 00 WA 0
0 4
[ 6] .comment PROGBITS 00000000 0141e0 000011 01 MS 0
0 1
[ 7] .debug_aranges MIPS_DWARF 00000000 0141f8 0003d8 00 0
0 8
[ 8] .debug_info MIPS_DWARF 00000000 0145d0 009794 00 0
0 1
[ 9] .debug_abbrev MIPS_DWARF 00000000 01dd64 00174a 00 0
0 1
[10] .debug_line MIPS_DWARF 00000000 01f4ae 001bfd 00 0
0 1
[11] .debug_frame MIPS_DWARF 00000000 0210ac 000adc 00 0
0 4
[12] .debug_str MIPS_DWARF 00000000 021b88 001a80 01 MS 0
0 1
[13] .debug_loc MIPS_DWARF 00000000 023608 005535 00 0
0 1
[14] .debug_ranges MIPS_DWARF 00000000 028b3d 000608 00 0
0 1
[15] .gnu.attributes LOOS+ffffff5 00000000 029145 000010 00 0
0 1
[16] .mdebug.abi32 PROGBITS 00000000 029155 000000 00 0
0 1
[17] .shstrtab STRTAB 00000000 029ab2 0000cf 00 0
0 1
[18] .symtab SYMTAB 00000000 029158 000600 10 19
49 4
[19] .strtab STRTAB 00000000 029758 00035a 00 0
0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
ABIFLAGS 0x0000b8 0x004000b8 0x004000b8 0x00018 0x00018 R 0x8
LOAD 0x000000 0x00400000 0x00400000 0x000d0 0x000d0 R 0x10000
LOAD 0x010000 0x80200000 0x80200000 0x040dc 0x040dc R E 0x10000
LOAD 0x0140e0 0x802140e0 0x802140e0 0x00100 0x00ac8 RW 0x10000
Section to Segment mapping:
Segment Sections...
00 .MIPS.abiflags
01 .MIPS.abiflags
02 .text .rodata
03 .got .bss
There is no dynamic section in this file.
There are no relocations in this file.
The decoding of unwind sections for machine type MIPS R3000 is not currently
supported.
Symbol table '.symtab' contains 96 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 80200000 0 SECTION LOCAL DEFAULT 1
2: 004000b8 0 SECTION LOCAL DEFAULT 2
3: 80202e98 0 SECTION LOCAL DEFAULT 3
4: 802140e0 0 SECTION LOCAL DEFAULT 4
5: 802141e0 0 SECTION LOCAL DEFAULT 5
6: 00000000 0 SECTION LOCAL DEFAULT 6
7: 00000000 0 SECTION LOCAL DEFAULT 7
8: 00000000 0 SECTION LOCAL DEFAULT 8
9: 00000000 0 SECTION LOCAL DEFAULT 9
10: 00000000 0 SECTION LOCAL DEFAULT 10
11: 00000000 0 SECTION LOCAL DEFAULT 11
12: 00000000 0 SECTION LOCAL DEFAULT 12
13: 00000000 0 SECTION LOCAL DEFAULT 13
14: 00000000 0 SECTION LOCAL DEFAULT 14
15: 00000000 0 SECTION LOCAL DEFAULT 15
16: 00000000 0 SECTION LOCAL DEFAULT 16
17: 00000000 0 FILE LOCAL DEFAULT ABS examples/api/demo.c
18: 802141e0 2048 OBJECT LOCAL DEFAULT 5 buf
19: 80203434 5 OBJECT LOCAL DEFAULT 3 __func__.3891
20: 00000000 0 FILE LOCAL DEFAULT ABS examples/api/crt0.o
21: 80200960 0 NOTYPE LOCAL DEFAULT 1 return_addr
22: 00000000 0 FILE LOCAL DEFAULT ABS examples/api/glue.c
23: 80214b58 20 OBJECT LOCAL DEFAULT 5 si
24: 80214b6c 60 OBJECT LOCAL DEFAULT 5 mr
25: 80214ae0 120 OBJECT LOCAL DEFAULT 5 devices
26: 802149e0 256 OBJECT LOCAL DEFAULT 5 env_name
27: 00000000 0 FILE LOCAL DEFAULT ABS examples/api/libgenwrap.c
28: 00000000 0 FILE LOCAL DEFAULT ABS lib/crc32.c
29: 80203448 1024 OBJECT LOCAL DEFAULT 3 crc_table
30: 00000000 0 FILE LOCAL DEFAULT ABS lib/div64.c
31: 00000000 0 FILE LOCAL DEFAULT ABS lib/string.c
32: 00000000 0 FILE LOCAL DEFAULT ABS lib/vsprintf.c
33: 80201bb4 304 FUNC LOCAL DEFAULT 1 put_dec_trunc
34: 80201ce4 292 FUNC LOCAL DEFAULT 1 string
35: 80201e08 488 FUNC LOCAL DEFAULT 1 put_dec
36: 80201ff0 964 FUNC LOCAL DEFAULT 1 number
37: 802040b8 16 OBJECT LOCAL DEFAULT 3 digits.3793
38: 802023b4 2560 FUNC LOCAL DEFAULT 1 vsnprintf_internal
39: 802040c8 17 OBJECT LOCAL DEFAULT 3 hex_asc
40: 00000000 0 FILE LOCAL DEFAULT ABS include/linux/ctype.h
41: 00000000 0 FILE LOCAL DEFAULT ABS lib/time.c
42: 00000000 0 FILE LOCAL DEFAULT ABS
43: 8021c0d0 0 NOTYPE LOCAL DEFAULT 4 _gp
44: 00000000 0 FUNC LOCAL DEFAULT UND get_tbclk
45: 00000000 0 FUNC LOCAL DEFAULT UND panic
46: 00000000 0 FUNC LOCAL DEFAULT UND simple_strtoul
47: 00000000 0 FUNC LOCAL DEFAULT UND timer_read_counter
48: 00000000 0 FUNC LOCAL DEFAULT UND simple_strtoull
49: 80202dd0 84 FUNC GLOBAL DEFAULT 1 vscnprintf
50: 80200a04 520 FUNC GLOBAL DEFAULT 1 test_dump_si
51: 80202e24 116 FUNC GLOBAL DEFAULT 1 printf
52: 802140dc 0 NOTYPE GLOBAL DEFAULT 4 _fdata
53: 8020194c 316 FUNC GLOBAL DEFAULT 1 __div64_32
54: 00000000 0 OBJECT GLOBAL DEFAULT UND _gp_disp
55: 80200920 56 FUNC GLOBAL DEFAULT 1 syscall
56: 80201118 32 FUNC GLOBAL DEFAULT 1 ub_puts
57: 802017b0 24 FUNC GLOBAL DEFAULT 1 puts
58: 80200980 132 FUNC GLOBAL DEFAULT 1 test_dump_sig
59: 80202db4 28 FUNC GLOBAL DEFAULT 1 vsnprintf
60: 80201794 28 FUNC GLOBAL DEFAULT 1 ub_display_clear
61: 80201a88 68 FUNC GLOBAL DEFAULT 1 strnlen
62: 80200974 0 OBJECT GLOBAL DEFAULT 1 search_hint
63: 802012d4 192 FUNC GLOBAL DEFAULT 1 ub_dev_enum
64: 80201244 84 FUNC GLOBAL DEFAULT 1 ub_get_timer
65: 80201138 28 FUNC GLOBAL DEFAULT 1 ub_reset
66: 80201098 68 FUNC GLOBAL DEFAULT 1 ub_getc
67: 80201208 60 FUNC GLOBAL DEFAULT 1 ub_udelay
68: 80200910 16 FUNC GLOBAL DEFAULT 1 __start
69: 80201918 52 FUNC GLOBAL DEFAULT 1 crc32
70: 80200000 0 NOTYPE GLOBAL DEFAULT 1 _ftext
71: 80201b58 92 FUNC GLOBAL DEFAULT 1 memcmp
72: 80200f24 372 FUNC GLOBAL DEFAULT 1 api_search_sig
73: 80203848 256 OBJECT GLOBAL DEFAULT 3 _ctype
74: 802141e0 0 NOTYPE GLOBAL DEFAULT 5 __bss_start
75: 80201acc 140 FUNC GLOBAL DEFAULT 1 memset
76: 80200000 2312 FUNC GLOBAL DEFAULT 1 main
77: 802010dc 60 FUNC GLOBAL DEFAULT 1 ub_putc
78: 8020140c 104 FUNC GLOBAL DEFAULT 1 ub_dev_close
79: 80200970 0 OBJECT GLOBAL DEFAULT 1 syscall_ptr
80: 80201660 224 FUNC GLOBAL DEFAULT 1 ub_env_enum
81: 80201474 212 FUNC GLOBAL DEFAULT 1 ub_dev_read
82: 802141e0 0 NOTYPE GLOBAL DEFAULT 4 _edata
83: 802140e0 0 OBJECT GLOBAL HIDDEN 4 _GLOBAL_OFFSET_TABLE_
84: 80214ba8 0 NOTYPE GLOBAL DEFAULT 5 _end
85: 80201740 84 FUNC GLOBAL DEFAULT 1 ub_display_get_info
86: 80201394 120 FUNC GLOBAL DEFAULT 1 ub_dev_open
87: 80200c0c 324 FUNC GLOBAL DEFAULT 1 test_dump_buf
88: 8020163c 36 FUNC GLOBAL DEFAULT 1 ub_env_set
89: 80201548 164 FUNC GLOBAL DEFAULT 1 ub_dev_send
90: 802015ec 80 FUNC GLOBAL DEFAULT 1 ub_env_get
91: 80201298 60 FUNC GLOBAL DEFAULT 1 ub_dev_get
92: 80201154 180 FUNC GLOBAL DEFAULT 1 ub_get_sys_info
93: 802141e0 0 NOTYPE GLOBAL DEFAULT 5 _fbss
94: 802017c8 336 FUNC GLOBAL DEFAULT 1 crc32_no_comp
95: 80200d50 468 FUNC GLOBAL DEFAULT 1 test_dump_di
No version information found in this file.
Attribute Section: gnu
File Attributes
Tag_GNU_MIPS_ABI_FP: Soft float
MIPS ABI Flags Version: 0
ISA: MIPS32r2
GPR size: 32
CPR1 size: 0
CPR2 size: 0
FP ABI: Soft float
ISA Extension: None
ASEs:
None
FLAGS 1: 00000001
FLAGS 2: 00000000
_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils