Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:44:32+00:00 2026-06-11T02:44:32+00:00

I am trying to link a static third party library compiled with RVCT 2.2

  • 0

I am trying to link a static third party library compiled with RVCT 2.2 with a test program compiled with GCC (arm-none-linux-gnueabi-gcc Sourcery G++ Lite 2011.03-41).

If I link with -static, everything works as it should. If I do not use -static however, I get lots of complaints like the following:

foolib.a(foo.o): In function `foofunc':
foo.c:(.text+0x4c8): undefined reference to `__aeabi_memcpy'
foolib.a(bar.o): In function `barfunc':
bar.c:(.text+0xa54): undefined reference to `__aeabi_memclr4'

Both memcpy and memset should be present in libc.
Clearly GCC can somehow detect and fix this if I use -static. Can someone explain what is happening? I assume that GCC dynamically links to libc unless I add the -static flag, but shouldn’t __aeabi_memcpy and similar be defined in the shared libc library as well?

EDIT:
In order to let people test this themselves I have now created a minimalistic test case like follows:

//foo.c
#include <string.h>

void foo(void *dst, void *src, int num) {
    memcpy(dst, src, num);
}

This file is compiled and archived with RVCT 2.2 as follows:

armcc.exe --arm -c --apcs=/noswst/interwork foo.c -o foo.o
armar.exe --create foo.a foo.o

This library is then linked with the following test program:

//bar.c
#include <stdio.h>
extern void foo(void *dst, void *src, int num);
int main(int argc, char *argv[]) {
    int a[10], b[10], i;

    for (i = 0; i < 10; i++) {
            a[i] = i;
    }

    foo(b, a, sizeof(a));

    for (i = 0; i < 10; i++) {
            if (a[i] != b[i]) {
                    printf("Diff at %d: %d != %d\n", i, a[i], b[i]);
                    return 1;
            }
    }
    printf("Success!\n");
    return 0;
}

Using the following command:

arm-none-linux-gnueabi-gcc -Wall bar.c foo.a -o bar

Which gives the following output (unless -static is also used):

foo.a(foo.o): In function `foo':
foo.c:(.text+0x0): undefined reference to `__aeabi_memcpy'
arm-none-linux-gnueabi/bin/ld: bar: hidden symbol `__aeabi_memcpy' isn't defined
arm-none-linux-gnueabi/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

The binary foo.a can be downloaded from http://dl.dropbox.com/u/14498565/foo.a in case you don’t have RVCT.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:44:33+00:00Added an answer on June 11, 2026 at 2:44 am

    After spending some time with this @Leo, I think I understand what’s going on. It appears that foo.o was compiled in a way that expects a static link to __aeabi_memcpy. Looking at foo.o with arm-none-linux-gnueabi-objdump -t, I see this:

    foo.o:     file format elf32-littlearm
    
    SYMBOL TABLE:
    00000000 l    df *ABS*  00000000 foo.c
    00000000 l    d  .text  00000000 .text
    00000000 l       *ABS*  00000000 BuildAttributes$$THUMB_ISAv1$ARM_ISAv4$M$PE$A:L22$X:L11$S22$IEEE1$IW$USESV6$~STKCKD$USESV7$~SHL$OSPACE$EBA8$REQ8$PRES8$EABIv2
    00000000 l     O .debug_frame$$$.text   00000000 C$debug_frame$$$.text7
    00000000  w    F *UND*  00000000 .hidden Lib$$Request$$armlib
    00000000       F *UND*  00000000 .hidden __aeabi_memcpy
    00000000 g     F .text  00000004 .hidden foo
    

    Note the -t in the command line… that’s for showing us the static symbols (non-shared). Running arm-none-linux-gnueabi-objdump -T on foo.o shows this:

    foo.o:     file format elf32-littlearm
    
    /home/jszakmeister/.local/sourcery-arm-gnueabi/bin/arm-none-linux-gnueabi-objdump: foo.o: not a dynamic object
    DYNAMIC SYMBOL TABLE:
    no symbols
    

    So __aeabi_memcpy is looking to be resolved via a static link, which is why using -static works. I believe if you compiled foo.o a little differently, so that it expects a shared C library, then you could link to foo.a without specifying -static. Unfortunately, I’m not familiar with the RVCT compiler, or I’d tell you how.

    FWIW, using strace I was able to see that it is indeed linking against the shared C library, but not resolving the link. I also used the --sysroot=/path/to/code/sourcery/toolchain/arm-none-linux-gnueabi/libc command line option to make sure it was finding the correct C library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to statically link to a third party C library in C++.
I am trying to link a static library [1] into another static library [2]
Im trying to link my program to the shared library. Im using a makefile
I'm trying to link to a static library and I keep getting linker errors.
I'm trying to create a simple static C++ library that I can link it
I am trying to link an application with multiple static libraries in GCC. There
Using MINGW, I'm trying to link my C code with a static C++ library
gcc 4.5.1 Fedora 14 Linux I have this static library that was build from
I'm trying to link a static library (.a) file with a .o file which
I'm trying to link to a static library, libcovis.a. Everything looks fine but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.