|
Message-ID: <20120120032051.GL132@brightrain.aerifal.cx>
Date: Thu, 19 Jan 2012 22:20:51 -0500
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Cc: "retnyg@....net" <retnyg@....net>
Subject: Re: [PATCH] fix lookup of ldso's dynamic section for GOLD linker
On Thu, Jan 19, 2012 at 05:53:10PM +0100, retnyg@....net wrote:
> here's a better one with only the necessary stuff.
> also it doesnt use sizeof but the correct value of each program
> header as stored in the elf header
Looks roughly correct now and it's clear that it's not changing
anything about load order. Thanks!
> >From 26754baff1ee5c5a8001c0b3ed5faddcd58b8ca3 Mon Sep 17 00:00:00 2001
> From: rofl0r <retnyg@....net>
> Date: Thu, 19 Jan 2012 14:54:39 +0100
> Subject: [PATCH] fix lookup of ldso's dynamic section for GOLD linker
>
> the previous code worked only with the ld linker.
> with the old technique, lib_dyn[DT_STRTAB] et al were 0.
> ---
> src/ldso/dynlink.c | 12 +++++++++++-
> 1 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
> index 86d4b80..ff12a78 100644
> --- a/src/ldso/dynlink.c
> +++ b/src/ldso/dynlink.c
> @@ -498,8 +498,18 @@ void *__dynlink(int argc, char **argv, size_t *got)
> }
> }
>
> + got[0] += aux[AT_BASE];
> +
Note that got[0] is still used later as the dynamic vector address,
but your patch does not set it correctly when the original value was
not the load-address-relative pointer to it...
> /* Relocate ldso's DYNAMIC pointer and load vector */
> - decode_vec((void *)(got[0] += aux[AT_BASE]), lib_dyn, DYN_CNT);
> + ehdr = (void*) aux[AT_BASE];
> + phdr = (Phdr*) ((char*) ehdr + ehdr->e_phoff);
> +
> + for(i = 0; i < ehdr->e_phnum; i++, phdr = (void *)((char *) phdr + ehdr->e_phentsize)) {
> + if (phdr->p_type == PT_DYNAMIC) {
> + decode_vec((void *) ((char*) ehdr + phdr->p_vaddr), lib_dyn, DYN_CNT);
> + break;
> + }
> + }
This looks correct. I'm making some relatively minor cosmetic changes.
By the way, in the future please attach patches rather than sending
them inline so the tabs don't get ruined, lines don't get wrapped,
etc. Mail bodies are generally not patch-clean.
See the attached patch and let me know if it looks ok..
Rich
View attachment "gold-issue.diff" of type "text/plain" (1413 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.