From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13453 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: optopt in getopt not being set, only when building with OpenWrt Date: Fri, 16 Nov 2018 22:11:00 +0100 Message-ID: <20181116211100.GJ21289@port70.net> References: 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 1542402549 19640 195.159.176.226 (16 Nov 2018 21:09:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 16 Nov 2018 21:09:09 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Paul Sykes To: musl@lists.openwall.com Original-X-From: musl-return-13469-gllmg-musl=m.gmane.org@lists.openwall.com Fri Nov 16 22:09:04 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 1gNlMO-00051C-JT for gllmg-musl@m.gmane.org; Fri, 16 Nov 2018 22:09:04 +0100 Original-Received: (qmail 15896 invoked by uid 550); 16 Nov 2018 21:11:13 -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 15871 invoked from network); 16 Nov 2018 21:11:12 -0000 Mail-Followup-To: musl@lists.openwall.com, Paul Sykes Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:13453 Archived-At: * 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. 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.