From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13457 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: optopt in getopt not being set, only when building with OpenWrt Date: Fri, 16 Nov 2018 16:38:45 -0500 Message-ID: <20181116213845.GM5150@brightrain.aerifal.cx> References: <20181116211100.GJ21289@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1542404214 17190 195.159.176.226 (16 Nov 2018 21:36:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 16 Nov 2018 21:36:54 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com, Paul Sykes Original-X-From: musl-return-13473-gllmg-musl=m.gmane.org@lists.openwall.com Fri Nov 16 22:36:49 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1gNlnE-0004L8-Qx for gllmg-musl@m.gmane.org; Fri, 16 Nov 2018 22:36:48 +0100 Original-Received: (qmail 14239 invoked by uid 550); 16 Nov 2018 21:38:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14218 invoked from network); 16 Nov 2018 21:38:57 -0000 Content-Disposition: inline In-Reply-To: <20181116211100.GJ21289@port70.net> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13457 Archived-At: On Fri, Nov 16, 2018 at 10:11:00PM +0100, Szabolcs Nagy wrote: > * Paul Sykes [2018-11-16 17:54:23 +0800]: > > On my OpenWrt builds I found that the optopt variable was never set > > when calling the function getopt. I tested the same code on my desktop > > using the gcc wrapper and optopt was set as expected. > > > > Debugging showed that optopt was being set correctly in getopt.c > > however the variable was not being set in my calling code. > > > > Adding optopt to the file 'dynamic.list' resolved the issue when > > building with OpenWrt. I noticed that all the other extern variables > > for getopt appear in dynamic.list except optopt. Yes, this is exactly right. It seems to have been an oversight. I'll push a fix for inclusion in 1.1.21, and distros using 1.1.20 should apply it since this is a notable regression. However, > yeah the dynamic list entry is needed so the address of the > object internally in the libc is the same as in the main > executable in case of copy relocation (only matters for > dynamic linked executables and pie executable may work > since that does not require copy relocs). > > all targets with copy relocs are affected, but only musl > version 1.1.20 has the problem i think. On distros using default-pie, the impact might be low, depending on arch, gcc version, and CFLAGS. There's never a *need* to use copy relocations with pie, and at one point gcc never did, but I think with current tooling it's more complicated whether copy relocations get used or not. Rich