why does the arm-poky-linux-gnueabi-gcc linker not use the definition of a symbol that it says it found on the C-library?

97 views Asked by At
#include<stdio.h>
//#include<sys/io.h>
extern        int ioperm(unsigned long from, unsigned long num, int turn_on);
int main()

{
 unsigned long from, num;
  int turn_on;
 ioperm( from,num,  turn_on);
 return 0;
}

When i link this program using

arm-poky-linux-gnueabi-gcc -Wl,--trace-symbol=ioperm -v -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=<$PWD>sdk/sysroots/armv7ahf-neon-poky-linux-gnueabi hello.o -o hello_out

The output looks like

<$PWD>/sdk/sysroots/armv7ahf-neon-poky-linux-gnueabi/lib/libc.so.6: definition of ioperm

hello.o:hello.c:function main: error: undefined reference to 'ioperm'

So, the linker finds this symbol as well but could not use it? Why?

If i see the dyn-syms on this library it is as below:

arm-poky-linux-gnueabi-readelf --dyn-syms <$PWD>/sdk/sysroots/armv7ahf-neon-poky-linux-gnueabi/lib/libc-2.31.so | grep ioperm 437: 000d4cf0 32 FUNC GLOBAL DEFAULT 13 ioperm@GLIBC_2.4

gcc version used is *gcc version 9.3.0 (GCC) *

I have another open embedded arm toolchain where the gcc compiler is arm-oe-linux-gnueabi-gcc. Its version is 6.4.0 where the glibc is libc-2.26.so and the symbol is defined as 418: 000dfcd8 396 FUNC WEAK DEFAULT 11 ioperm@@GLIBC_2.4 In this open-embedded toolchain, the symbol is linked correctly. How can i get more information from the linker on why it did not use the symbol definition in the yocto toolchain? Also, in the yocto toolchain, this symbol is not declared anywhere as the header-file <sys/io.h> is missing as well. I wonder why the glibc says the definition is found even though the header is not even present?

Also, on the yocto toolchain, only this symbol causes a problem. Other C-language sumbols did not have any problem with the linker.

1

There are 1 answers

1
Ross Burton On

From the ioperm manpage:

"This call is mostly for the i386 architecture. On many other architectures it does not exist or will always return an error."

glibc before 2.30 had implementations that were, in the words of the code, "a fiction", After that they don't exist.

Basically, unless you're on 32-bit x86, don't use ioperm() and friends.