我使用RTEMS 4.11和内置的POSIX函数动态地将程序映像加载到内存中。使用以下代码在RTEMS中加载程序映像:
void* handle = dlopen(prog_name, RTLD_NOW | RTLD_GLOBAL);
if (!handle)
printf("dlopen: %s\n", dlerror());我使用RTEMS构建的GCC编译内存文件系统中位于prog_name的对象。
我应该使用哪个命令行来正确编译一个C文件以便以这种方式加载?
作为参考,我尝试了以下命令行选项,但得到了一个错误:
$ /opt/rtems-4.11/bin/sparc-rtems4.11-gcc test.c -c -o test.elf -shared -fPIC -nostdlib
$ # dlopen: global symbol not found: _GLOBAL_OFFSET_TABLE_
$ /opt/rtems-4.11/bin/sparc-rtems4.11-gcc test.c -o test.elf -fPIC -shared -nostdlib
$ # dlopen: ELF file contains program headers我还尝试了其他一些组合,也使用了rtems-ld程序。有什么想法吗?
发布于 2018-09-18 07:01:49
事实证明,唯一重要的选项是-c (编译和组装,但不链接)。
$ /opt/rtems-4.11/bin/sparc-rtems4.11-gcc test.c -c -o test.elf
$ # this now workshttps://stackoverflow.com/questions/52371011
复制相似问题