This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] elf: Unify symbol address run-time calculation [BZ #19818]


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."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]