This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/2] elf: Unify symbol address run-time calculation [BZ #19818]
- From: Andreas Schwab <schwab at suse dot de>
- To: "Maciej W. Rozycki" <macro at mips dot com>
- Cc: <libc-alpha at sourceware dot org>, "H.J. Lu" <hjl dot tools at gmail dot com>, Alan Modra <amodra at gmail dot com>, "Cary Coutant" <ccoutant at gmail dot com>
- Date: Mon, 19 Feb 2018 14:46:47 +0100
- Subject: Re: [PATCH 1/2] elf: Unify symbol address run-time calculation [BZ #19818]
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.00.1802191042010.3553@tp.orcam.me.uk> <alpine.DEB.2.00.1802191059150.3553@tp.orcam.me.uk>
On Feb 19 2018, "Maciej W. Rozycki" <macro@mips.com> wrote:
> Index: glibc/sysdeps/generic/ldsodefs.h
> ===================================================================
> --- glibc.orig/sysdeps/generic/ldsodefs.h 2018-02-16 20:46:56.455844235 +0000
> +++ glibc/sysdeps/generic/ldsodefs.h 2018-02-16 20:54:43.029923370 +0000
> @@ -66,14 +66,20 @@ __BEGIN_DECLS
> /* Result of the lookup functions and how to retrieve the base address. */
> typedef struct link_map *lookup_t;
> #define LOOKUP_VALUE(map) map
> -#define LOOKUP_VALUE_ADDRESS(map) ((map) ? (map)->l_addr : 0)
> +#define LOOKUP_VALUE_ADDRESS(map, set) ((set) || (map) ? (map)->l_addr : 0)
> +
> +/* Calculate the address of symbol REF using the base address from map MAP,
> + if non-NULL. Don't check for NULL map if MAP_SET is TRUE. */
> +#define SYMBOL_ADDRESS(map, ref, map_set) \
> + ((ref) == NULL ? 0 \
> + : LOOKUP_VALUE_ADDRESS ((map), (map_set)) + (ref)->st_value)
No need for double parens, since uses of arguments must already be
properly parenthesized.
> /* On some architectures a pointer to a function is not just a pointer
> to the actual code of the function but rather an architecture
> specific descriptor. */
> #ifndef ELF_FUNCTION_PTR_IS_SPECIAL
> # define DL_SYMBOL_ADDRESS(map, ref) \
> - (void *) (LOOKUP_VALUE_ADDRESS (map) + ref->st_value)
> + (void *) SYMBOL_ADDRESS ((map), (ref), false)
Likewise.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."