Re: Elf64_Phdr
On Tue, 2019-06-25 at 22:09 +, Sasha Da Rocha Pinheiro wrote: > > What happens if I call elf64_newphdr() on the same Elf * but with > different size_t __cnt? It creates a new phdr table for the Elf with cnt entries, whether or not the phdr table existed or not. If cnt is zero any existing table is removed. > What happens to the previous headers? Using references to them become invalid. Cheers, Mark
Re: Elf64_Phdr
On Wed, 2019-06-26 at 20:01 +, Sasha Da Rocha Pinheiro wrote: > So, I need to write an elf file. I have an open Elf * handle with > read only permission. I then need to update the program headers and > next add a new program header entry. > For that we create an Elf * handle with write permission, and create > the headers doing: > elf64_newphdr(new_elf, old_elf->e_phnum) > for loop: memcpy(newPhdr, oldPhdr, oldEhdr->e_phentsize); > > This is done because prior to memcpy, I perform changes (updates) in > the values in the copied program headers. Best to do this with: /* Get the number of program headers in the ELF file. If the file uses more headers than can be represented in the e_phnum field of the ELF header the information from the sh_info field in the zeroth section header is used. */ extern int elf_getphdrnum (Elf *__elf, size_t *__dst); Also, if you want to support either 64 or 32 bit ELF files, then using gelf_getphdr () and gelf_updatephdr () in the loop might be better than the memcpy. > Now I need to add a new program header. How can I insert a new > program header to the ones copied to newPhdr? The problem here is > that I need to assess with the updated headers where to place a new > header. It seems I can't call elf64_newphdr again on the new_elf > handle. Yes, if you want to shuffle the phdrs around and/or insert headers then you need to keep around copies of the original headers. You could use your own array of Elf64_Phdr or GElf_Phdr for that. Note that in the case of gelf_getphdr () you already provide your own storage, so that might be another reason to prefer the gelf interfaces. Cheers, Mark
Linux Plumbers Toolchain Micro-Conference CFP
Hi people! This is a call for proposals for the Toolchain micro-conference at this years' Linux Plumbers Conference (LPC) 2019 which will be held in Lisbon, Portugal for September 9-11. The Linux kernel is particularly demanding in terms of tooling, and the main purpose of this micro-conference is to increase collaboration between the kernel and toolchain developers. To that effect, we encourage short presentations (one or two slides) to briefly introduce the topic to be discussed, followed by actual discussion between toolchain and kernel hackers. Examples of topics we want to cover in the MC: * Header harmonization between kernel and glibc * Wrapping syscalls in glibc * eBPF support in toolchains * Potential impact/benefit/detriment of recently developed GCC optimizations on the kernel * Kernel hot-patching and GCC * Online debugging information: CTF and BTF * Development and parity between GCC and LLVM If you work on some toolchain area and want to come and discuss it with kernel developers, please send your proposal using the form in: https://www.linuxplumbersconf.org/event/4/abstracts/ Please make sure to specify that the proposal is for the Toolchains MC. For any special inquiry, you can contact the organizer of the MC: jema...@gnu.org Proposals must be submitted until August 2nd, and submitters will be notified of acceptance at latest by August 9. Looking forward to see you in Lisbon!