This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more infromation.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
G'day, this is probably somewhat off-topic, but I'm stuck and I guess some people on this list might have some tips for me, here goes: I need to extract some specific data from a solaris2.4 object file (a kernel driver). I need to extract the soc_ucode data from the /kernel/drv/soc file. I first cross compiled binutils-2.9.5 on my linux-i386 box to a sparc-sun-solaris2.4 target. That worked fine and indeed I can run nm, objdump, readelf, etc. on the driver file with success. The problem is however that I don't seem to grasp where the actual code is to extract (e.g. what the byte offset if from the start of the file). I just need to dd the data out of the file, the size I need to dd is 32K which is the size of the soc_ucode data type. Here are some outputs : [root@proxy:/home/users/devel/devel/usr-sparc/bin]$ ./sparc-sun-solaris2.4-nm soc | grep ucode 000000f8 D soc_ucode 000080f8 D soc_ucode_end ... [root@proxy:/home/users/devel/devel/usr-sparc/bin]$ ./sparc-sun-solaris2.4-objdump --syms soc | grep ucode 00000000 l df *ABS* 00000000 soc_ucode.c 000080f8 g O .data 00000004 soc_ucode_end 000000f8 g O .data 00008000 soc_ucode .... [root@proxy:/home/users/devel/devel/usr-sparc/bin]$ ./sparc-sun-solaris2.4-readelf -a soc | grep ucode 00002254 08d09 R_SPARC_HI22 000000f8 soc_ucode + 0 00002258 08d0c R_SPARC_LO10 000000f8 soc_ucode + 0 00002270 06609 R_SPARC_HI22 000080f8 soc_ucode_end + 0 00002278 0660c R_SPARC_LO10 000080f8 soc_ucode_end + 0 82: 0 0 FILE LOCAL 0 ABS soc_ucode.c 102: 80f8 4 OBJECT GLOBAL 0 3 soc_ucode_end 141: f8 32768 OBJECT GLOBAL 0 3 soc_ucode .... [root@proxy:/home/users/devel/devel/usr-sparc/bin]$ ./sparc-sun-solaris2.4-readelf -a soc | more ELF Header: Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: REL (Relocatable file) Machine: Sparc Version: 0x1 Entry point address: 0x0 Start of program headers: 0 (bytes into file) Start of section headers: 66776 (bytes into file) Flags: 0x0 Size of this header: 52 (bytes) Size of program headers: 0 (bytes) Number of program headers: 0 Size of section headers: 40 (bytes) Number of section headers: 14 Section header string table index: 10 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS 00000000 000038 004bb8 00 AX 0 0 8 [ 2] .rodata1 PROGBITS 00000000 004bf0 000230 00 A 0 0 4 [ 3] .data PROGBITS 00000000 004e20 0080fc 00 WA 0 0 4 [ 4] .data1 PROGBITS 00000000 00cf1c 00099e 00 WA 0 0 4 [ 5] .bss NOBITS 00000000 00d8bc 000004 00 WA 0 0 4 [ 6] .symtab SYMTAB 00000000 00d8bc 0009a0 10 7 53 4 [ 7] .strtab STRTAB 00000000 00e25c 00078e 00 0 0 1 [ 8] .stab.index PROGBITS 00000000 00e9ec 000048 0c 0 0 4 [ 9] .comment PROGBITS 00000000 00ea34 00002c 00 0 0 1 [10] .shstrtab STRTAB 00000000 00ea60 000076 00 0 0 1 [11] .rela.text RELA 00000000 00ead8 0016c8 0c 6 1 4 [12] .rela.data RELA 00000000 0101a0 0000cc 0c 6 3 4 [13] .stab.indexstr STRTAB 00000000 01026c 00026a 00 0 0 1 Now I started out with this last listing and took 0x004e20 as the starting offset (the offset of the .data segment) and added 0xf8 to that, so basically : unsigned long offset = 0x004e20 + 0xf8 ; fseek(stream, offset, SEEK_SET); copy_file_32k(); This however doesn't seem to work because the data I end up seems to be invalid. My question is ; how do I compute the acuall offset of the soc_ucode data in this file ? Any tips would be greatly appreciated, Cheers, flux. ------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |