From: 陳韋任 <ch...@cs...> - 2010-11-10 07:24:48
|
Hi, all: I plan to add some data into an elf file, then retrieve those data back when running the elf file. I would like to use libelf to get the job done. For adding data into an elf file, I found 'objcopy --add-section sectionname=filename theElf' can do the same thing without using libelf. Am I right? Will 'objcopy' update all related entries? Or I have to use libelf to do it? Then for retrieving data within a particular section, I tried to use those API mentioned in the tutorial "libelf by Example" written by Joseph. I found the procedure was quite different from my original thought. At first, I tended to iterate though the section header table. With the "sh_name" member in the section header table entry and shstrndx, I could find the section I want by comparing the section name. However, what I done now was iterating though all sections, NOT section header table, then got associated section table entry and compared the section name. It's pretty much like the program 4 (listing all section names) in the tutorial "libelf by Example". I don't know if it is the only way to get data in a particular section. Any suggestion will be appreciated. Regards, chenwj -- Wei-Jen Chen (陳韋任) Programming Language and System Laboratory (EC131) Department of Computer Science, National Chiao Tung University |