Different behavior when linking with gcc and ld: Unable to link __aeabi_uldivmod when link with arm-none-eabi-ld

Asked by Thong Dam

When I tried to link source code with:
arm-none-eabi-ld -T linker.ld $(OBJECT_FILES) -L $(LIB_PATH) -lm -lc

There is error that "undefined reference to `__aeabi_uldivmod ' ". This project will build successfully when I tried to remove the instruction which required this API.

I also be able to link the same object file with arm-none-eabi-gcc:
arm-none-eabi-gcc -nostartfiles -T$(LINKER_FILE) -Os -g -Wall -mcpu=cortex-r7 -mthumb -mfpu=vfpv4 -mfloat-abi=hard -L $(LIB_DIRS) -lm -lc
It event work without needed for -L and -l (however I need them for additional math library).

So my question are:
1. What is the different between these 2 approaches? Why it did not work with LD version?
2. Is there any drawback when I link project use GCC command?

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Ramana Radhakrishnan (ramana) said :
#1

Try adding a -lgcc to your link flags. - this is because there's no instruction to do a divmod and your program had a call out to a libgcc helper function. Since you aren't using the compiler driver and the linker directly the link error shows up.

Ramana

________________________________________
From: <email address hidden> <email address hidden> on behalf of Thong Dam <email address hidden>
Sent: 07 October 2020 04:40
To: gnu-rm-support
Subject: [Gnu-rm-support] [Question #693328]: Different behavior when linking with gcc and ld: Unable to link __aeabi_uldivmod when link with arm-none-eabi-ld

New question #693328 on GNU Arm Embedded Toolchain:
https://answers.launchpad.net/gcc-arm-embedded/+question/693328

When I tried to link source code with:
arm-none-eabi-ld -T linker.ld $(OBJECT_FILES) -L $(LIB_PATH) -lm -lc

There is error that "undefined reference to `__aeabi_uldivmod ' ". This project will build successfully when I tried to remove the instruction which required this API.

I also be able to link the same object file with arm-none-eabi-gcc:
arm-none-eabi-gcc -nostartfiles -T$(LINKER_FILE) -Os -g -Wall -mcpu=cortex-r7 -mthumb -mfpu=vfpv4 -mfloat-abi=hard -L $(LIB_DIRS) -lm -lc
It event work without needed for -L and -l (however I need them for additional math library).

So my question are:
1. What is the different between these 2 approaches? Why it did not work with LD version?
2. Is there any drawback when I link project use GCC command?

--
You received this question notification because your team GCC Arm
Embedded Maintainers is an answer contact for GNU Arm Embedded
Toolchain.

_______________________________________________
Gnu-rm-support mailing list
<email address hidden>
http://listhost.cambridge.arm.com/mailman/listinfo/gnu-rm-support
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Can you help with this problem?

Provide an answer of your own, or ask Thong Dam for more information if necessary.

To post a message you must log in.