Gcc-arm Bare Metal Development essay----Solve the problem of link standard library

Source: Internet
Author: User
Tags join

The paper is recorded in the Linux environment with the cross-tool chain to develop arm bare metal programs encountered some problems and solutions, mainly to solve the problem of the process and a number of small experience, small skills recorded. Now, some of the things that feel a bit of value are moved to the blog for readers ' reference.

-----------------12.16-----------------

22:25
Compiling a bare-metal program using a cross-tool chain requires the old error in division. Later, the library LIBGCC.A in the Cross tool chain was added to the link option with-l and-L, but still no, the error remains. The error message is: Undefined reference to ' __aeabi_uidiv '.

Later sent a post to inquire, see here:

http://bbs.csdn.net/topics/390318464?page=1#post-393232299

-----------------12.17-----------------

18:00
In response to yesterday's problem, a new test project was created specifically for the division problem. I found yesterday that I did not have a custom makefile implicit rule, and the system default implicit rule compilation does not use the Ccflag I define. A little bit of progress, but after the modification, found the error remains. Later in the directory that found the LIBGCC library yesterday, other libraries starting with LIBGCC also added to the connection options, and found that it was still not working.

During the test, it was found that when I divide using two int integers, I am prompted that __aeabi_idiv cannot be found, and __aeabi_uidiv when dividing with two uint types. So guess _idiv refers to the int type Div, while _uidiv refers to the unsigned int type div. __aeabi is not clear what it stands for.

18:20
Eh Looks like a little bit of progress. Yesterday, the LIBM join link option was found to be the reason why the makefile hidden rule was not rewritten yesterday, because that means that, in addition to the build rules that I wrote start.o myself, for other. o files created with the makefile default implicit rules, the ccflag I define is useless. Now that the LIBM Library has been re-added to the connection option, I finally see raise. Specific as follows:
/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/lib/libm.so:undefined reference to ' raise@glibc_2.4 '
/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/lib/libm.so:undefined reference to ' __errno _location@glibc_2.4 '
/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/lib/libm.so:undefined reference to ' fwrite@glibc_2.4 '
/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/lib/libm.so:undefined reference to ' _rtld_ Global_ro@glibc_private '
/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/lib/libm.so:undefined reference to ' sprintf@glibc_2.4 '
There's still behind, no writing. But it seems not quite right, because I found that there are warning:
Arm-linux-ld:warning:ld-linux.so.3, needed by/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/ Usr/lib/libm.so, not found (try Using-rpath or-rpath-link)
Arm-linux-ld:warning:libc.so.6, needed by/opt/friendlyarm/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root/usr/ Lib/libm.so, not found (try Using-rpath or-rpath-link)
start.o:in function ' _start ':
(. text+0x0): Undefined reference to ' __aeabi_uidiv '
It is mentioned here that I joined the LIBM library may also need to use ld-linux.so.3 and libc.so.6, these are not under the system. I'm going to write a bare-metal. Also, I am a static link, but here it appears. So library, Halo. And the __aeabi_uidiv in my compilation are still not recognized.


23:02
All kinds of test can not, LD really let people but pain. But to find a new law, it can be used, LED lights can flash. This method is directly using the ARM-LINUX-GCC itself with the link tool, instead of using ARM-LINUX-LD.
$ (CC)-v-static-wl,-t,my.lds,-ttext,0x50000000,-map,$ (name). Map-nostartfiles-o $ (name). Elf $ (OBJ)
$ (objcopy)-o binary $ (name). Elf $ (name). bin #接着将boot. Elf->boot.bin

That's fine. About ARM-LINUX-GCC,
#-V shows detailed procedures for compiling links
#-static Static Links
#-wl,-tubl_davinci.lds,-map,system.map these parameters to the linker (separated by commas, not spaces)
#-nostartfiles tells GCC not to join the startup file.

Reference: http://blog.chinaunix.net/uid-2282111-id-2113244.html

It seems arm-linux-ld and ARM-LINUX-GCC to bring the connection tool still a little check other, take time to study.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.