makefile - Including a separate binary into an ELF executable -


i developing operating system. include small asm program main kernel elf can serve first process load. having trouble getting work. program initcode.s. using following makefile modified xv6 operating system source task:

initcode:     $(as) $(asflags) initcode.s -o initcode.o     ld $(ldflags) -n -e start -ttext 0 -o initcode initcode.o     objcopy --input binary --output elf32-i386 --binary-architecture i386 initcode.out initcode   kernel.elf: $(objects) initcode     ld -t link.ld -melf_i386 $(objects) -o kernel.elf initcode 

the kernel compiles , links fine. objcopy creates markers enable me find binary within kernel code. contents of initcode trashed. contents not resemble assembler step produced within initcode.out.

how can achieve including initcode.s separate binary somewhere in main kernel.elf markers generated can find within kernel? suggestions?

i can think of 2 simple methods. there more complex methods if prefer.

  1. write small utility convert initcode binary asm file (or c file) containing gas data section. assemble file , link kernel. initcode appear variable in kernel.

or

  1. simply 'cat' initcode binary end of kernel elf after link step. method depend on whether loader happy support this.

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -