Missing __init_array_start in dynamic lib

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Smilediver
Member
Member
Posts: 37
Joined: Sun Aug 05, 2007 4:23 pm

Missing __init_array_start in dynamic lib

Post by Smilediver »

Anyone knows when __init_array_start gets a definition? When I check my newlib port, it shows that it is a weak(?) link:

Code: Select all

$ nm /usr/local/cross/i386-pc-shmix/lib/libc.so | grep __init_array_start
         w __init_array_start
When I check the application linked to newlib, the __init_array_start symbol is defined here.

Code: Select all

$ nm ../software/testlibc/testlibc.elf | grep __init_array_start
08001000 A __init_array_start
So, is this how it's supposed to be, and newlib's __init_array_start symbol should be dynamically linked in runtime to the program's __init_array_start? Or I understood something wrong.

Another thing... I think my newlib doesn't get initialized... the _init function is just empty:

Code: Select all

$ gdb /usr/local/cross/i386-pc-shmix/lib/libc.so
(gdb) disas _init
Dump of assembler code for function _init:
0x00026588 <_init+0>:   push   %ebp
0x00026589 <_init+1>:   mov    %esp,%ebp
0x0002658b <_init+3>:   leave
0x0002658c <_init+4>:   ret
End of assembler dump.
Is this releated to the __init_array_start symbol, so that when I link my program to the lib, the lib's initialization routines are put in the program's __init_array_start?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

I assume that 1) you have a dynamic linker already working and 2) you've got newlib to work statically already?
Smilediver
Member
Member
Posts: 37
Joined: Sun Aug 05, 2007 4:23 pm

Post by Smilediver »

JamesM wrote:I assume that 1) you have a dynamic linker already working and 2) you've got newlib to work statically already?
1) Kind of... It works, but not everything is implemented. Anyway, it's enough to call functions from the lib like sprintf. I think it lacks that kind of linking, when lib uses symbols from the program. And I'm not sure how libs are initialized (I call _init, but it's just empty).

2) Well, I have to admit I haven't tried to link statically to my program, cause I want it to be dynamically linked.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Try and get it working statically first. It takes about 2 seconds to compile and link, and you can debug it easier. Walk before you can run, would be my advice.

JamesM
Smilediver
Member
Member
Posts: 37
Joined: Sun Aug 05, 2007 4:23 pm

Post by Smilediver »

I've recompiled bash as static, and it gets to the bash prompt and reading loop without any trouble, so I assume that newlib is working fine. Unfortunately, dynamically linked bash doesn't work the same way. I suspect that symbol search in my dynamic linker isn't working the way it should... Arghh... the docs are so vague, and I have to make so many assumptions that any could be wrong. :-(
Post Reply