From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9100 Path: news.gmane.org!not-for-mail From: Markus Wichmann Newsgroups: gmane.linux.lib.musl.general Subject: Re: dynamic linker command line invocation Date: Tue, 12 Jan 2016 17:24:02 +0100 Message-ID: <20160112162402.GJ2016@debian> References: <20160104205920.GW238@brightrain.aerifal.cx> <20160105173200.GZ238@brightrain.aerifal.cx> <20160105182326.GB238@brightrain.aerifal.cx> <20160108110954.GC2016@debian> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1452615858 13793 80.91.229.3 (12 Jan 2016 16:24:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 Jan 2016 16:24:18 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9113-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jan 12 17:24:17 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aJ1k0-00089v-Ua for gllmg-musl@m.gmane.org; Tue, 12 Jan 2016 17:24:17 +0100 Original-Received: (qmail 26514 invoked by uid 550); 12 Jan 2016 16:24:15 -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 26488 invoked from network); 12 Jan 2016 16:24:14 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:FpvD/Wj5lgBs8etJWQ+TdNw/9pqeV5rXlcVUZrjmC5nHgROTb05 nkAFstfsfNUEV3OJIxOKfn5d3mRyS1yGuc6AzEQ0vQSMthG1HI2WPtS109EkV9XK7diYHsR wXFvoMUKpIUkohaBRTc2u5sTR/EHIgCONz9mqPEwyrhFQ6vxpOvGDI36I5jOog3mrPj1Sg/ KkgU+GftxyfQkNQKP0gAg== X-UI-Out-Filterresults: notjunk:1;V01:K0:GVayk+wwRAs=:+kVIGOfdPvBYsZmFFliu3v TQ2KH4eLd7szhA6mIhhlG/C/RGZDgjA0FSOPzLFZFKM07c7po5bQ9hsbn7ZP1i3wvD8IJz3bd WHn0kLYPwUZJknenNA9H/ofr+cKdGpmm152Lv0VkkFYEEpaZxWWhghx/7VL7h0J+EXxq8K1UP 5mfPoiKZMkIN4RHjec4G7e5RAnzn877r3WFdQmE9ltsjMlf+VGvtlRQtWiOezLcgqZghd0mCi CzHLRRgx+Pa/F6KuEFgYX9yJxvlrYKif5onL5tOel2Mi10FVP79IEb5nRIzj0wg0hYeg/GMaU 50fiLqGZu7bQoAWpp1qAkl8zFW4QjDWK9HK6ACJHigFAyv7BAVxguXBr0qotkDKKY7PxcG2xm afJdRGavO2X82B7jljQlcU66N3E5W8H00iPqkzvxzIljEOsW4KdTZGXA3U8wtgBisk70xF67Z lsZ13DrqMmLTp02kG1DcgVDUcPrm95GeIVPEMaGHd+uXqCq3k7RtKNOsZuDU/HAyQfsd4qruY g2EKDYUnLXHlW58AeHOxyssrgi4Qnh/4xo2KATJeyrwK7zxx9jrEnmbqpQ/z8lENE92IlhFEH gJLGUEXhqjViHLsmKffRUuaZV0WCeYolZ1qSjurjFFCtzO9r2l+ZEeoB916cTKHvDrL6lMrIf FA89or8PX1C/7G0gPiX6gp9XYG9UFTkTSiaou6N77jdHtdsdySEhpVBEQG8pyYRDGZM06M8Nc CpQFH+oi9o3mhodGBWMH14XTA41fhhiNmERZUGAPa5pIp7AB+wti8ocAOeE= Xref: news.gmane.org gmane.linux.lib.musl.general:9100 Archived-At: On Mon, Jan 11, 2016 at 12:03:37PM -0500, N Jain wrote: > Hi Marcus, > > Thanks. I am able to get this part working. > I am facing one more issue during dynamic linking and need some help to > understand how to resolve it. > > In below code part of __dls3 function I found that TPIDRURO register is > being used to read the threadId. > I would like to understand how kernel should set this value ? > It shouldn't. musl calls __set_thread_area() (in __init_tp()), and that has to set this register. The kernel is only involved, if musl has to do a syscall there. > As per my understanding kernel should allocate memory and set this register > for current task. Generally, no. The allocation is up to the application. But on some architectures, the kernel has to add a bit of stuff to the list of things to be swapped on task switch (e.g. on i386 the TLS segment descriptors in the GDT). For more information, ask your architecture's system programming manual. > But when i do this in my kernel the values doesn't match up as MUSL is > using some "builtin_tls" ? > > /* Temporarily set the tls size to the full size of > * builtin_tls so that __copy_tls will use the same layout > * as it did for before. Then check, just to be safe. */ > libc.tls_size = sizeof builtin_tls; > if (__copy_tls((void*)builtin_tls) != self) a_crash(); > If you get there, __init_tp() was already called, so the thread pointer should be set to builtin_tls. (Or rather, should be set such that __copy_tls() will return the current thread pointer). If that isn't the case then something has already gone wrong. Check __init_tp()! Ciao, Markus