From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124487 invoked by alias); 19 Feb 2018 13:46:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 124476 invoked by uid 89); 19 Feb 2018 13:46:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1643 X-HELO: mx2.suse.de From: Andreas Schwab To: "Maciej W. Rozycki" Cc: , "H.J. Lu" , Alan Modra , "Cary Coutant" Subject: Re: [PATCH 1/2] elf: Unify symbol address run-time calculation [BZ #19818] References: X-Yow: LOU GRANT froze my ASSETS!! Date: Mon, 19 Feb 2018 16:14:00 -0000 In-Reply-To: (Maciej W. Rozycki's message of "Mon, 19 Feb 2018 13:31:07 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-02/txt/msg00505.txt.bz2 On Feb 19 2018, "Maciej W. Rozycki" 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."