Re: BINFMT_FLAT: reloc outside program
Greg Ungerer <[email protected]> Thu, 7 Apr 2016 15:25:41 +1000
| Newsgroups | gmane.linux.uclinux.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Waldemar, On 05/04/16 20:49, Waldemar Brodkorb wrote: > Hi uClinux/elf2flt devs, > > How can I debug an issue with the following error while > executing: > ~ # ./hello > BINFMT_FLAT: reloc outside program 0xb5890000 (0 - 0x125a4/0x8b0c), > killing hello! > SEGV > > The target is an ARM Cortex-M4 device. The error is only happening > when libpthread from uClibc-ng is used in the binary. Non-threading > applications are working fine. (Linuxthreads.old used) > The problem was reported by Thomas Petazzoni from Buildroot project. > > On the build system I used this example code: > http://timmurphy.org/2010/05/04/pthreads-in-c-a-minimal-working-example/ > > $ /usr/bin/arm-openadk-uclinux-uclibceabi-gcc -o hello hello.c -lpthread > $ /usr/bin/arm-openadk-uclinux-uclibceabi-flthdr -k hello > $ /usr/bin/arm-openadk-uclinux-uclibceabi-flthdr -p hello > hello > Magic: bFLT > Rev: 4 > Build Date: Tue Apr 5 12:28:25 2016 > Entry: 0x45 > Data Start: 0x8b4c > Data End: 0xe384 > BSS End: 0x125e0 > Stack Size: 0x1000 > Reloc Start: 0xe384 > Reloc Count: 0x197 > Flags: 0x11 ( Load-to-Ram Kernel-Traced-Load ) > > On the target system: > ~ # ./hello > BINFMT_FLAT: Loading file: ./hello > Mapping is 70020000, Entry point is 45, data_start is 8b4c > Load ./hello: TEXT=70020040-70028b4c DATA=70028b50-7002e388 > BSS=7002e388-700325e4 > BINFMT_FLAT: reloc outside program 0xb5890000 (0 - 0x125a4/0x8b0c), > killing hello! > SEGV > > You can find readelf, objdump -x, objdump -D and the source of > hello.c here: > http://debug.openadk.org/arm-pthreads/ If you compile supplying "-v" in the elf2flt flags then it will produce a verbose output that contains all the relocation information. That will be helpful here. (Post it here too if you want). > Stracing the process does not work: > ~ # ./strace ./hello > BINFMT_FLAT: Loading file: ./hello > ./strace: Can't attach to 45: No such process > ~ # Mapping is 70560000, Entry point is 45, data_start is 8b4c > Load ./hello: TEXT=70560040-70568b4c DATA=70568b50-7056e388 > BSS=7056e388-705725e4 > BINFMT_FLAT: reloc outside program 0xb5890000 (0 - 0x125a4/0x8b0c), > killing hello! strace won't help you here. The program isn't running yet, the relocation failure is at exec time. > gdbserver (gdb 7.11) does not compile for me as it uses fork(): > build-gnulib-gdbserver/import/libgnu.a > build-libiberty-gdbserver/libiberty.a -lthread_db > linux-low.o: In function `linux_create_inferior': > linux-low.c:(.text+0x25d2): undefined reference to `fork' > linux-ptrace.o: In function `linux_child_function': > linux-ptrace.c:(.text+0x24): undefined reference to `fork' > linux-ptrace.o: In function `linux_check_ptrace_features': > linux-ptrace.c:(.text+0x10a): undefined reference to `fork' > thread-db.o: In function `thread_db_init': > thread-db.c:(.text+0x520): undefined reference to `td_thr_tlsbase' > collect2: error: ld returned 1 exit status That won't help you here either (at least for this specific problem). It is the exec step this program that is failing. > I searched the internet and found that it might be stack size > related. But even compiling example code and C library with > -Wl,-elf2flt=-s16384 didn't help. Ok, that is always a good thing to try first. > Any help is appreciated, The verbose elf2flt output may give some clues. You may need to instrument the kernel's fs/binfmt_flat.c code to match up reloc numbers though if nothing is obviously wrong in the verbose reloc information. Regards Greg _______________________________________________ uClinux-dev mailing list [email protected] http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by [email protected] To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev