Prelink error: Layout error: section size too small for data

641 views Asked by At

I am running prelink on an ARM system with Linux 2.6.35. I am using Glibc 2.12.2. I would like to prelink my libraries and application executables. However, I can't seem to link anything that relies directly upon glibc. When prelink tries to run on /lib, it errors out with:

Could not write /lib/libc-2.12.2.so: Layout error: section size too small for data

Is there a way for me to fix this or perhaps convince prelink to prelink everything except what resides in /lib? I am aware of the blacklisting feature in /etc/prelink.conf, but then prelink will error out because it cannot find dependencies located in that directory.

Edit:

Here is my prelink.conf

~ # cat /etc/prelink.conf
-h /usr/local/Qt-4.7.4/lib
-h /usr/lib
-h /lib
-h /usr/local/dbus/lib
-h /usr/local/sqlite/lib
-h /usr/local/ncurses/lib
-h /usr/local/expat/lib
-h /usr/local/ssl/lib

I am on the i.MX51 platform by Freescale. It is an ARM Cortex-8. Being that I have compiled everything with the GCC/G++ version that came with our development kit, I assume that the ELF binaries are 32-bit.

Edit:

I changed the -h flags to -l's and moved the system libs to the front of the list. I still get the same error.

I am running prelink on the device, not on my cross-building machine.

LD_LIBRARY_PATH contains /lib and /usr/lib

Tried running prelink as: prelink -a prelink -amR

and got the same result both ways.

I am running gcc 4.4.6 cross compiler. I am running ld 1.12.1 ld.

1

There are 1 answers

3
Appleman1234 On

The error Layout error: section size too small for data is called in libelf on the following line https://github.com/path64/compiler/blob/master/src/libelf/lib/update.c#L230.

This gets called by prelink in write_dso

if (elf_update (dso->elf, ELF_C_WRITE) == -1)
  return 2;

write_dso gets called by update_dso which gets called in main.c of prelink along with a few other places.

This happens because the size of the section data being relocated is larger than the section size it is being relocated to.

What prelink command are you running ?

What is your prelink.cache ?

Are your binaries / libraries ELF32 or ELF64 ?

The file utility will tell you.

What are the gcc version, binutil version, libelf and prelink versions?

gcc -V will tell you. Along with ld -V and prelink -V.

What is your LD_LIBRARY_PATH ?

The set or env command will tell you.

What options was glibc compiled with ? Specifically with regards to -fPIC ?

Are you running prelink on the device itself ? or in a cross compile environment ?

Why does your prelink configuration have no -l lines ? -h lines will follow symlinks which might not be what you want if your build root has symlinks in library directories ? Also normally the /lib and /usr/lib entries go first in a prelink.conf like the example here.

Are you running prelink with the -m switch to converse virtual memory? If you blacklist everything in /lib, then I believe you can't prelink any library or binary that links to a library in /lib, similarly if you blacklist /lib/libc-2.12.2.so then you can't prelink to anything that links to it , as a prelinked file needs its libraries to be prelinked as well.

As for a possible fix, without having more information, it is hard to say, but it could be related to incorrect switches passed to prelink or mixing 32 bit or 64 bit libraries in the same directory in prelink cache or configuration file.

Further information on linking and prelink is avaliable