customize rootfs

stanlyJ
Hi,

I'm trying to run ubuntu from sdcard on mini6410 and at the same time be
able to use java on it without installing it in the Flash memory of the
board, so i downloaded the jdk for arm from oracle website from here : 

http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-arm-...

and then i extracted the archive and put the folder in /opt of
rootfs-ubuntu-0910 folder. I changed the files ~/.bashrc of allusers (root,
ubuntu, and fa) and then i used the mktools to create my .ext3 image that i
use from sdcard.

The system runs finee, but the problem is that when i try to use java
commands (like java, or javac) or even when i try to execute the scripts,
it gives me the following message :

/opt/jdk1.7.0_45/jre/bin/java: No such file or directory

when i navigate to the folder, and list the files, "java" is listed as a
binary file, with execution permission. when i try to run it the system
cannot find it.

So before asking for help i'll tell you what i already tried.

i tried to create a new FriendlyARM.cpio containing the /opt folder, and
with the good initialisation of the variable path in the script "init"
that you can find after extracting the cpio. when i tried to use it to
compile a new image of the kernel, it gave me the following error : 

linux-2.6.28.6/arch/arm/mm/proc-v6.S:227: relocation truncated to fit:
R_ARM_JUMP24 against `.text.init'
make: *** [.tmp_vmlinux1] Error 1

so any help about how to customize the filesystem and use it properly would
be appreciated, and also i'll be delighted if someone can tell me what's
the file "FriendlyARM.cpio" is really used for in the kernel, i tried to
look for it, but no answers.

Thanks in advance.

davef
Is "java" cross-compiled for the correct ARM platform?

What does:
   readelf -a <filename> say about the 4th or 5th line from the end of the
output?  

Just a guess.

stanlyJ
Hi davef,

here's the feedback of the command readelf -a ./java : 

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x8470
  Start of program headers:          52 (bytes into file)
  Start of section headers:          2368 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5
EABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         31
  Section header string table index: 28

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk
Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0  
0  0
  [ 1] .interp           PROGBITS        00008134 000134 000019 00   A  0  
0  1
  [ 2] .note.ABI-tag     NOTE            00008150 000150 000020 00   A  0  
0  4
  [ 3] .note.gnu.build-i NOTE            00008170 000170 000024 00   A  0  
0  4
  [ 4] .hash             HASH            00008194 000194 000048 04   A  5  
0  4
  [ 5] .dynsym           DYNSYM          000081dc 0001dc 000080 10   A  6  
1  4
  [ 6] .dynstr           STRTAB          0000825c 00025c 0000e4 00   A  0  
0  1
  [ 7] .gnu.version      VERSYM          00008340 000340 000010 02   A  5  
0  2
  [ 8] .gnu.version_r    VERNEED         00008350 000350 000040 00   A  6  
2  4
  [ 9] .rel.dyn          REL             00008390 000390 000008 08   A  5  
0  4
  [10] .rel.plt          REL             00008398 000398 000020 08   A  5 
12  4
  [11] .init             PROGBITS        000083b8 0003b8 00000c 00  AX  0  
0  4
  [12] .plt              PROGBITS        000083c4 0003c4 000044 04  AX  0  
0  4
  [13] .text             PROGBITS        00008408 000408 000200 00  AX  0  
0  4
  [14] .fini             PROGBITS        00008608 000608 000008 00  AX  0  
0  4
  [15] .rodata           PROGBITS        00008610 000610 000020 00   A  0  
0  4
  [16] .ARM.exidx        ARM_EXIDX       00008630 000630 000008 00  AL 13  
0  4
  [17] .eh_frame         PROGBITS        00008638 000638 000004 00   A  0  
0  4
  [18] .init_array       INIT_ARRAY      0001063c 00063c 000004 00  WA  0  
0  4
  [19] .fini_array       FINI_ARRAY      00010640 000640 000004 00  WA  0  
0  4
  [20] .jcr              PROGBITS        00010644 000644 000004 00  WA  0  
0  4
  [21] .dynamic          DYNAMIC         00010648 000648 000110 08  WA  6  
0  4
  [22] .got              PROGBITS        00010758 000758 000020 04  WA  0  
0  4
  [23] .data             PROGBITS        00010778 000778 000008 00  WA  0  
0  4
  [24] .bss              NOBITS          00010780 000780 000004 00  WA  0  
0  1
  [25] .comment          PROGBITS        00000000 000780 000064 01  MS  0  
0  1
  [26] .ARM.attributes   ARM_ATTRIBUTES  00000000 0007e4 000031 00      0  
0  1
  [27] .gnu_debuglink    PROGBITS        00000000 000815 000014 00      0  
0  1
  [28] .shstrtab         STRTAB          00000000 000829 000115 00      0  
0  1
  [29] .symtab           SYMTAB          00000000 000e18 000670 10     30 
78  4
  [30] .strtab           STRTAB          00000000 001488 000280 00      0  
0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  EXIDX          0x000630 0x00008630 0x00008630 0x00008 0x00008 R   0x4
  PHDR           0x000034 0x00008034 0x00008034 0x00100 0x00100 R E 0x4
  INTERP         0x000134 0x00008134 0x00008134 0x00019 0x00019 R   0x1
      [Requesting program interpreter: /lib/ld-linux-armhf.so.3]
  LOAD           0x000000 0x00008000 0x00008000 0x0063c 0x0063c R E 0x8000
  LOAD           0x00063c 0x0001063c 0x0001063c 0x00144 0x00148 RW  0x8000
  DYNAMIC        0x000648 0x00010648 0x00010648 0x00110 0x00110 RW  0x4
  NOTE           0x000150 0x00008150 0x00008150 0x00044 0x00044 R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4

 Section to Segment mapping:
  Segment Sections...
   00     .ARM.exidx 
   01     
   02     .interp 
   03     .interp .note.ABI-tag .note.gnu.build-id .hash .dynsym .dynstr
.gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini
.rodata .ARM.exidx .eh_frame 
   04     .init_array .fini_array .jcr .dynamic .got .data .bss 
   05     .dynamic 
   06     .note.ABI-tag .note.gnu.build-id 
   07     

Dynamic section at offset 0x648 contains 29 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libjli.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000e (SONAME)                     Library soname: [lib.so]
 0x0000000f (RPATH)                      Library rpath:
[$ORIGIN/../lib/arm/jli]
 0x0000000c (INIT)                       0x83b8
 0x0000000d (FINI)                       0x8608
 0x00000019 (INIT_ARRAY)                 0x1063c
 0x0000001b (INIT_ARRAYSZ)               4 (bytes)
 0x0000001a (FINI_ARRAY)                 0x10640
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x00000004 (HASH)                       0x8194
 0x00000005 (STRTAB)                     0x825c
 0x00000006 (SYMTAB)                     0x81dc
 0x0000000a (STRSZ)                      228 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x10758
 0x00000002 (PLTRELSZ)                   32 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x8398
 0x00000011 (REL)                        0x8390
 0x00000012 (RELSZ)                      8 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x8350
 0x6fffffff (VERNEEDNUM)                 2
 0x6ffffff0 (VERSYM)                     0x8340
 0x00000000 (NULL)                       0x0

Relocation section '.rel.dyn' at offset 0x390 contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00010774  00000315 R_ARM_GLOB_DAT    00000000   __gmon_start__

Relocation section '.rel.plt' at offset 0x398 contains 4 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
00010764  00000216 R_ARM_JUMP_SLOT   000083d8   __libc_start_main
00010768  00000316 R_ARM_JUMP_SLOT   00000000   __gmon_start__
0001076c  00000416 R_ARM_JUMP_SLOT   000083f0   JLI_Launch
00010770  00000716 R_ARM_JUMP_SLOT   000083fc   abort

Unwind table index '.ARM.exidx' at offset 0x630 contains 1 entries:

0x8470 <_start>: 0x1 [cantunwind]


Symbol table '.dynsym' contains 8 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00000000     0 NOTYPE  WEAK   DEFAULT  UND
_ITM_deregisterTMCloneTab
     2: 000083d8     0 FUNC    GLOBAL DEFAULT  UND
__libc_start_main@GLIBC_2.4 (2)
     3: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
     4: 000083f0     0 FUNC    GLOBAL DEFAULT  UND
JLI_Launch@SUNWprivate_1.1 (3)
     5: 00000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
     6: 00000000     0 NOTYPE  WEAK   DEFAULT  UND
_ITM_registerTMCloneTable
     7: 000083fc     0 FUNC    GLOBAL DEFAULT  UND abort@GLIBC_2.4 (2)

Symbol table '.symtab' contains 103 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00008150     0 NOTYPE  LOCAL  DEFAULT    2 $d
     2: 00008470     0 NOTYPE  LOCAL  DEFAULT   13 $a
     3: 00008630     0 NOTYPE  LOCAL  DEFAULT   16 $d
     4: 000084a0     0 NOTYPE  LOCAL  DEFAULT   13 $d
     5: 00008610     0 NOTYPE  LOCAL  DEFAULT   15 $d
     6: 00010778     0 NOTYPE  LOCAL  DEFAULT   23 $d
     7: 000084ac     0 NOTYPE  LOCAL  DEFAULT   13 $a
     8: 000084ac     0 FUNC    LOCAL  DEFAULT   13 call_gmon_start
     9: 000084c8     0 NOTYPE  LOCAL  DEFAULT   13 $d
    10: 000083b8     0 NOTYPE  LOCAL  DEFAULT   11 $a
    11: 00008608     0 NOTYPE  LOCAL  DEFAULT   14 $a
    12: 000083c0     0 NOTYPE  LOCAL  DEFAULT   11 $a
    13: 0000860c     0 NOTYPE  LOCAL  DEFAULT   14 $a
    14: 00008408     0 NOTYPE  LOCAL  DEFAULT   13 $a
    15: 00008464     0 NOTYPE  LOCAL  DEFAULT   13 $d
    16: 00008614     0 NOTYPE  LOCAL  DEFAULT   15 $d
    17: 00010644     0 OBJECT  LOCAL  DEFAULT   20 __JCR_LIST__
    18: 000084d0     0 NOTYPE  LOCAL  DEFAULT   13 $a
    19: 000084d0     0 FUNC    LOCAL  DEFAULT   13 deregister_tm_clones
    20: 000084fc     0 NOTYPE  LOCAL  DEFAULT   13 $d
    21: 00008508     0 NOTYPE  LOCAL  DEFAULT   13 $a
    22: 00008508     0 FUNC    LOCAL  DEFAULT   13 register_tm_clones
    23: 0000853c     0 NOTYPE  LOCAL  DEFAULT   13 $d
    24: 0001077c     0 NOTYPE  LOCAL  DEFAULT   23 $d
    25: 00008548     0 NOTYPE  LOCAL  DEFAULT   13 $a
    26: 00008548     0 FUNC    LOCAL  DEFAULT   13 __do_global_dtors_aux
    27: 0000856c     0 NOTYPE  LOCAL  DEFAULT   13 $d
    28: 00010780     1 OBJECT  LOCAL  DEFAULT   24 c...stripped-down

stanlyJ
here are the last lines of the output, they don't seem to be pasted  here :


Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "6"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_VFP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align8_needed: Yes
  Tag_ABI_align8_preserved: Yes, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6
  Tag_unknown_44: 1 (0x1)

Juergen Beisert
> /opt/jdk1.7.0_45/jre/bin/java: No such file or directory

This kind of error message occurs when some needed libraries are missing.

You already got the list of required libraries by using the 'readelf'
command:

 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libjli.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so.2]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]

Are these libs present in your target's root filesystem?

stanlyJ
@Juergen Beisert

Thanks for the answer but all the files you mentioned are available on the
target filesystem, so any other guesses ? i'll be so glad if you help me
solve this problem

Juergen Beisert
Run your java engine with the 'strace' command and see what the shell tries
to run it.

stanlyJ
solved it, davef was right, the files i used were for chips that have
hardware support for floating point "hflt", while S3C6410 has a software
support for floating point, so when i've put the right files on, it worked
like a charm, thank you guys.

PS: i still need information about FriendlyARM.cpio if anyone can help, all
i know is that this file contains some sort of filesystem that will be
loaded in the RAM, so correct me if i'm wrong, and give me some more info
if you can.

Thanks again.

Reggie
it's in /scripts/ in the kernel sources, you can open it like a zip file. 
no idea how you edit one though, whenever I did, I broke stuff.

stanlyJ
@Reggie: My question is about what's (friendlyarm.cpio) used for in the
kernel not where would i find it. and for your information the following
link is showing a scenario in which he user had to customize
friendlyarm.cpio, i didn't manage to do the same thing, but still the topic
contains cool stuff to know, hope you enjoy the reading :

http://www.friendlyarm.net/forum/topic/2385

Juergen Beisert
"[...] were for chips that have hardware support for floating point "hflt",
while S3C6410 has a software support for floating point [...]"

This is not hardware related, it's just toolchain related (compiler,
assember, linker). The ARMv6 in the S3C6410 SoC supports hardware floating
point. If the toolchain makes use of it, it can use the floating point
register when calling functions or still the CPU main registers. That's why
libs and programs from different toolchains cannot be mixed.
Once more it is important to build the whole system with one toolchain.

For the records (ouput from the 'readelf -a <targetfile>' command):

Hardware floating point support with CPU's main registers usage:

  Tag_CPU_name: "ARM1136JF-S"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_ABI_optimization_goals: Aggressive Speed
  Tag_CPU_unaligned_access: v6
  Tag_DIV_use: Not allowed

Hardware floating point support with floating point registers usage:

  Tag_CPU_name: "ARM1136JF-S"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_ABI_VFP_args: VFP registers
  Tag_ABI_optimization_goals: Aggressive Speed
  Tag_CPU_unaligned_access: v6
  Tag_DIV_use: Not allowed

And here the output without any hardware floating point support:

  Tag_CPU_name: "4T"
  Tag_CPU_arch: v4T
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_optimization_goals: Aggressive Speed
  Tag_DIV_use: Not allowed

stanlyJ
@ Juergen Beisert :

So it's a toolchain related issues, programs cannot use libs that were not
compiled using the same toolchain, that's clear enough now, thank you for
the clarification. Do you have anything to tell me about FriendlyARM.cpio ?
I'll be glad to hear (or in this case to read).