Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined symbol #9

Closed
paulwratt opened this issue Aug 4, 2018 · 5 comments
Closed

undefined symbol #9

paulwratt opened this issue Aug 4, 2018 · 5 comments

Comments

@paulwratt
Copy link
Contributor

paulwratt commented Aug 4, 2018

ok, almost there, now I am getting:
obj/emutospp.ld:127: undefined symbol '__mulsi3' referenced in expression

In emutos.ld, is the following RPi specific or cross-GCC specific:

ELF_LIB_REF(__mulsi3)
ELF_LIB_REF(__divsi3)
ELF_LIB_REF(__modsi3)
ELF_LIB_REF(__udivsi3)
ELF_LIB_REF(__umodsi3)
ELF_LIB_REF(__aeabi_idiv)
ELF_LIB_REF(__aeabi_idivmod)
ELF_LIB_REF(__aeabi_udiv)
ELF_LIB_REF(__aeabi_uidiv)
ELF_LIB_REF(__aeabi_udivmod)
ELF_LIB_REF(__aeabi_uidivmod)

why are they hard coded? how can these symbols be present in assembled code if they are NOT present in the libs they reference (libgcc.a in this case).

when I do arm-none-eabi-nm /usr/lib/gcc/arm-none-eabi/4.8/libgcc.a | grep "__mul" I get:

00000000 T __muldf3
00000000 T __mulsf3
00000000 T __muldi3
00000000 T __mulvsi3
00000000 T __mulvdi3
00000000 T __mulsc3
00000000 T __muldc3

and when I do arm-none-eabi-nm /usr/lib/gcc/arm-none-eabi/4.8/libgcc.a | grep "_muls" I get:

00000000 T __mulsf3
_mulsc3.o:
00000000 T __mulsc3
00000000 T __gnu_mulsq3
00000000 T __gnu_mulsa3

same with fpu/libgcc.a. by the way on RPi this usually indicates the need for -lm and a specific -L directory. but I also notice there are no "i" references there either, except __mulvsi3 & __mulvdi3.
however all the "aeabi"+"idiv" references seem to be present

I will try non-cross with gcc-6.1.0 tomorrow, as I read in a baremetal tut that you dont need arm-none-eabi when compiling on the actual hardware (just static linking).

actually I just checked 6.1.0 with /usr/local/gcc-6.1.0/bin/gcc-nm-6.1.0 /usr/local/gcc-6.1.0/lib/gcc/arm-linux-gnueabihf/6.1.0/libgcc.a | grep muls and I get the exact same as above, also with GCC 4.9, so it looks like some of those symbols are not present on actual Raspbian/Debian for Pi.

edit: I just checked a arm-none-eabi/4.8.3 not from the repo, and it is also the same.

I could probably #if defined(RPI) & !defined(QEMU) the actual values in, presuming this is the right thing to do (I dont have a m68k-atari-mint on any Raspbian distro to triple check)

@kelihlodversson
Copy link
Owner

kelihlodversson commented Aug 4, 2018 via email

@paulwratt
Copy link
Contributor Author

are you sure, because in theory you should also be getting the error too, and ur not (are you?). is it a Intel build thing (vincents cross tools are on ubuntu). Are u using Windows or Linux to do ur builds?

@paulwratt
Copy link
Contributor Author

paulwratt commented Aug 4, 2018

some of them are needed, but I did not have to add any, so this was acceptable:

/*
ELF_LIB_REF(__mulsi3)
ELF_LIB_REF(__divsi3)
ELF_LIB_REF(__modsi3)
ELF_LIB_REF(__udivsi3)
ELF_LIB_REF(__umodsi3)
*/
ELF_LIB_REF(__aeabi_idiv)
ELF_LIB_REF(__aeabi_idivmod)
/* ELF_LIB_REF(__aeabi_udiv) */
ELF_LIB_REF(__aeabi_uidiv)
/* ELF_LIB_REF(__aeabi_udivmod) */
ELF_LIB_REF(__aeabi_uidivmod)

how come you dont get the errors? and how can this be scripted? (the QEMU option is looking mighty fine atm)

I am not 100% sure, but it is more than likely things will be the same with ANY GCC on actual RPi Raspbian (I will try to grab a latest Raspbian image and maybe GCC 7 or 8 to test next week to confirm). I would be interested to see if its the same for Raspbian x86 as well, it might be an Intel thing.

@kelihlodversson
Copy link
Owner

Looks like your version of ld requiers the target symbols to be known in a PROVIDE or EXTERN directive.
I've moved the ref's that you identified as not being needed and/or defined on the RPI into an #if !defined(MACHINE_RPI)

@paulwratt
Copy link
Contributor Author

just to confirm, these are still needed when building on RPi Raspbian:

ELF_LIB_REF(__aeabi_idiv)
ELF_LIB_REF(__aeabi_idivmod)
ELF_LIB_REF(__aeabi_uidiv)
ELF_LIB_REF(__aeabi_uidivmod)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants