[uClinux-dev] BINFMT_RELOC error when linking to pthreads
Sean McGranaghan
smm at appcongroup.com
Tue Feb 5 16:23:27 EST 2008
Hello all,
I have an application that fails to load with the following message
"BINFMT_FLAT: reloc outside program." I am using the Freescale
MCF5208EVBe platform and cross tools that come with the Steroidmicro
eval board. (SBCToolsV3 - GCC 3.4.0) I also have an independent build
from the uClinux Coldfire distro. I have seen similar issues in the list
archives but I am at a loss as to how to fix this. Here is a dirt simple
application which fails:
#include <stdio.h>
#include <semaphore.h>
typedef struct
{
void (*func)(void);
}
FUNC;
static void func(void)
{
}
static FUNC fcntbl[] =
{
{ func },
};
int main(int argc, char *argv[])
{
sem_t s;
sem_init(&s, 0, 0);
return 0;
}
This application uses a statically initialized global table and links to
an external library (pthreads). Both of these conditions seem to be
necessary to generate the loader error. I did not see a single solution
to the problem on the list. In an effort to solve this in the past it
looks like there were two approaches:
1. Shuffle around sections in the elf2flt linker script. I think the
intent was to avoid a conflict with C++ constructors and globally
initialized data.
2. Modify binfmt_flat.c, suspecting a bug in either the relocation
macros of ntoh macros.
So which is it? A link script issue or a loader issue? I am hoping this
is just a matter of getting my compiler flags setup correctly and
matching the options used to build the libraries. Building for a flat
memory model seems a bit tricky.
Please feel free to redirect me as necessary, any help is *greatly*
appreciated.
Thanks,
Sean McGranaghan
More information about the uClinux-dev
mailing list