#1
|
|||
|
|||
Need help figuring out why my powerpc elf file causing seg fault
Hello,
basically, i am trying to embed a vxworks image into an elf binary (a simple hello world c application), just to see if it is possible. if it is possible, i plan to use call cast on the c code to verify certain functions inside vxworks image. but after weeks, i find no way to make this elf run without seg fault (using qemu-ppc). thus, i need help. so, i used debian, and the commands were like these : Code:
powerpc-linux-gnu-objcopy -I binary -O elf32-powerpc -B powerpc vxs vxw.o powerpc-linux-gnu-objcopy --set-section-flags .data=alloc,load,code vxw.o powerpc-linux-gnu-objcopy --rename-section .data=.vxworks vxw.o powerpc-linux-gnu-gcc -Wall -Werror -g hello.c -o myprog -T myscript vxw.o -static Code:
#include <stdio.h> extern unsigned char _binary_vxs_start; extern unsigned char _binary_vxs_end; int main() { printf("Hello World!\n"); unsigned char *pblob = &_binary_vxs_start; int i = 0; while (i < 100) { printf("%x: %02X\n", pblob - &_binary_vxs_start, *pblob); i++; pblob++; } return 0; } Code:
powerpc-linux-gnu-ld --verbose Code:
... /* Read-only sections, merged into text segment: */ /* PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x10000000)); . = SEGMENT_START("text-segment", 0x10000000) + SIZEOF_HEADERS; */ PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x000FFF4C)); . = SEGMENT_START("text-segment", 0x000FFF4C) + SIZEOF_HEADERS; .vxworks : { *(.vxworks) } .interp : { *(.interp) } ... tried to compare both working elf and notworking elf with readelf, the not working one, doesn't have __ehdr_start. i tried to add that symbol in the linker script : Code:
__ehdr_start = 0x000FFF4C; any help appreciated. thanks in advance. |
#2
|
||||
|
||||
Works perfectly fine for me just following your steps.
I do not understand why you change segment_start though? And where does 0x000FFF4C come from? I am attaching my tests, sw versions I used: Quote:
|
The Following User Gave Reputation+1 to deepzero For This Useful Post: | ||
dion (06-14-2021) |
The Following User Says Thank You to deepzero For This Useful Post: | ||
dion (06-13-2021) |
#3
|
|||
|
|||
Ok i'll poke the elephant in the room
Quote:
|
#4
|
|||
|
|||
Quote:
when i used default loading address(0x10000000), the vx section loaded at (0x100000b4). so, i figured, i just need to substract to get loaded to 0x00100000, which is 0x000FFF4C. btw, i got : Code:
Error while loading myprog: Permission denied |
#5
|
|||
|
|||
yes, because it's what i worked on. i am not trying to implement something on source level, but to verify certain crypto function inside.
|
#6
|
||||
|
||||
makes sense, and since the file works for me but not for you the issue has to be in your setup...
Try Quote:
Or attach gdb Quote:
|
#7
|
|||
|
|||
tried in ubuntu 20.04, installed the bintools and gcc, it works.
must be bug somewhere. thank you deepzero |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Codepack (PowerPC) | sobaker | General Discussion | 0 | 10-30-2004 04:34 |
FS and GS referring fault in TR | shellkiller | General Discussion | 0 | 03-02-2002 10:29 |