dlopen failed: file not found

Saeed Ehteshamifar salpha.2004 at gmail.com
Thu Jul 28 07:18:27 UTC 2016


Hi,

On Thu, Jul 28, 2016 at 4:22 AM, Chris Johns <chrisj at rtems.org> wrote:

> On 28/07/2016 08:05, Saeed Ehteshamifar wrote:
>
>> Hello,
>>
>> I followed the instructions Chris posted on using WAF to make a TAR
>> object file and linked it to my program. But when I run it, I get "file
>> not found" error. I'm using SPARC SIS.
>>
>> Here is my waf script:
>> import rtems_waf.rtems as rtems
>>
>> def init(ctx):
>>      rtems.init(ctx)
>>
>> def options(opt):
>>      rtems.options(opt)
>>
>> def configure(conf):
>>      rtems.configure(conf)
>>
>> def build(bld):
>>      rtems.build(bld)
>>
>>      rtems.root_filesystem(bld, 'dl',
>>          ['init.c',
>>          'hello.c'],
>>          'dl.tar', 'dl-tar.o')
>>
>>
> How do you build the tar file into the executable?
>

Via linking dl-tar.o to my application. This is the Makefile:

PGM=${ARCH}/dl.exe

# optional managers required
MANAGERS=all

# C source names
CSRCS = init.c hello.c
COBJS = $(CSRCS:%.c=${ARCH}/%.o)
COBJS += build/sparc-rtems4.12-sis/dl-tar.o

include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg

OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)

all:    ${ARCH} $(PGM)

$(PGM): $(OBJS)
    $(make-exe)



>
>
>>
>> And here is how I untar the object in my Init task and load the dynamic
>> object, which should print "Hello":
>> ...
>> extern int _binary_dl_tar_start;
>> extern int _binary_dl_tar_size;
>>
>> rtems_task Init(
>>    rtems_task_argument ignored
>> )
>> {
>>    int (*hello)();
>>
>>    int te = Untar_FromMemory((void *)(&_binary_dl_tar_start),
>>                          (size_t)(_binary_dl_tar_size));
>>    /* error checking. omitted here. */
>>
>
> I suggest you print the error code here.
>

I omitted untar error handling for simplicity. In fact it looks like:

  if (te != 0)
  {
    printf("untar failed: %d\n", te);
    exit (1);
  }


>
> Chris
>
>
>>    void* handle = dlopen ("/hello.o", RTLD_NOW | RTLD_GLOBAL);
>>    if (!handle)
>>    {
>>      printf("dlopen failed: %s\n", dlerror());
>>      exit(1);
>>    }
>> ...
>>
>> What am I doing wrong? Using /objdump/ and /nm/ I didn't find ANY
>> occurrence of /hello /in the final executable file.
>>
>> Best Regards,
>> Saeed
>>
>>
>> _______________________________________________
>> users mailing list
>> users at rtems.org
>> http://lists.rtems.org/mailman/listinfo/users
>>
>>
What could be the problem that *hello* object is not found (dlopen failed:
file not found)?

Best Regards,
Saeed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20160728/e3a65305/attachment-0002.html>


More information about the users mailing list