Relinker util?
Ian Lance Taylor
ian@airs.com
Thu Feb 28 08:03:00 GMT 2002
More information about the Binutils mailing list
Thu Feb 28 08:03:00 GMT 2002
- Previous message (by thread): Relinker util?
- Next message (by thread): Relinker util?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mike Perry <mikepery@fscked.org> writes: > Hey guys. Is there a way to add new object files into a pre-exisiting > statically linked binary? Or a way add a new .so file to the library > list of a dynamic library (by actually PERMANENTLY modifying the binary, > ie not LD_PRELOAD)? No. > What would be the best way to approach this? I was thinking of just > modifying the ELF program header by hand to expand like the last segment > in the file and throwing some code down there. Would using something like > libBFD be a better choice? Simply modifying the ELF program header is an interesting approach. Since the last LOAD segment normally includes the BSS (i.e., the memsz is larger than the filesz) you will have to write out some zeroes for the BSS. The last LOAD segment is also normally not executable, so technically you can not add instructions there. However, very few processors--perhaps none--enforce that restriction. However, you didn't mention why you want to do this. Simply adding new code in the text section is not going to cause it to be called by anything. To get that code to be called by anything within the program, you would have to ensure that the relocations were retained, and you have to adjust them. To get that code to be called by anything outside the program (e.g., using dlopen), you would have to frob the dynamic symbol table. Neither operation is nearly as simple as just dumping new text into the binary. Ian
- Previous message (by thread): Relinker util?
- Next message (by thread): Relinker util?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list