Some problem in dlopen on Raspberry Pi

Pavel Pisa ppisa4lists at pikron.com
Thu May 19 12:50:55 UTC 2016


Hello Chris,

as you know I am testing Raspberry Pi to integrate
previous work and help this year GSoC students
and I am testing dlopen on the current RTEMS master.

My previous tests on LPC17xx, MPC5200, i386 and after
some of your corrections even TMS570
worked nicely. But I have noticed some strange problem
with RPi1. It is a little newer master with U-boot
fixes but that should not be a problem, I hope.

The test code

--------------------------------------------------
#include <stdio.h>

int main(int argc, char *argv[])
{
  int i;
  printf("%s: dynamicaly loaded code called\n", argv[0]);
  for (i = 1; i < argc; i++) {
    printf("%s: argument %i: %s\n", argv[0], i, argv[i]);
  }
  return 0;
}
--------------------------------------------------

is compiled to the ELF object file. I use

  handle = dlopen (call_file_name, RTLD_NOW | RTLD_GLOBAL);
  ...
  if (dlinfo (handle, RTLD_DI_UNRESOLVED, &unresolved) < 0)
    message = "dlinfo error checking unresolved status";
  else if (unresolved)
    message = "has unresolved externals"; /* check and print */
  ...
  call = dlsym (handle, call_symbol);
  if (call == NULL) {
  ...
  call_ret = call(argc, argv);

All seem to be right to this place but when I disassemble target
function I get

   0x1cb018:	push	{r4, r5, r6, r7, r8, lr}
   0x1cb01c:	mov	r7, r0
   0x1cb020:	mov	r6, r1
   0x1cb024:	ldr	r0, [pc, #64]	; 0x1cb06c
   0x1cb028:	ldr	r1, [r1]
   0x1cb02c:	bl	0x1cb02c
                        !!!!!!!!!!!!!!!
   0x1cb030:	cmp	r7, #1
   0x1cb034:	ble	0x1cb064
   0x1cb038:	mov	r5, r6
   0x1cb03c:	mov	r4, #1

It seem that call to printf function is not updated.

Symbols reported by object file are

omk-template/appdl/rootfs/bin/appdl_print-rpi1.o: ELF 32-bit LSB relocatable, 
ARM, version 1 (SYSV), not stripped
00000000 t $a
00000054 t $d
00000000 r $d
00000010 N $d
00000000 T main
         U printf

readelf reports

Relocation section '.rel.text.startup.main' at offset 0x1730 contains 4 
entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00000014  0000161c R_ARM_CALL        00000000   printf
00000040  0000161c R_ARM_CALL        00000000   printf
00000054  00000802 R_ARM_ABS32       00000000   .rodata.main.str1.4
00000058  00000802 R_ARM_ABS32       00000000   .rodata.main.str1.4

Symbol table '.symtab' contains 23 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 FILE    LOCAL  DEFAULT  ABS appdl_print.c
     ....
    20: 00000000     0 SECTION LOCAL  DEFAULT   22
    21: 00000000    92 FUNC    GLOBAL DEFAULT    4 main
    22: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND printf

So it looks mostly OK.

Have you some idea.

Best wishes,

             Pavel


More information about the devel mailing list