From owner-svn-src-all@freebsd.org Fri Oct 27 18:34:40 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C805AE4E2B2; Fri, 27 Oct 2017 18:34:40 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3764D73116; Fri, 27 Oct 2017 18:34:40 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v9RIYYK4060196 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Oct 2017 21:34:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v9RIYYK4060196 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v9RIYYaM060195; Fri, 27 Oct 2017 21:34:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 27 Oct 2017 21:34:34 +0300 From: Konstantin Belousov To: mmel@freebsd.org Cc: Brooks Davis , Dimitry Andric , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, kib@freebsd.org Subject: Re: svn commit: r324938 - head/contrib/jemalloc/include/jemalloc/internal Message-ID: <20171027183434.GK2566@kib.kiev.ua> References: <201710232131.v9NLV4Rb068825@repo.freebsd.org> <38db6f4e-72b8-6ffd-4529-f15ca32bad54@freebsd.org> <6FD27DFB-5039-4E33-B131-EF5391DD1630@FreeBSD.org> <6eff6e66-4987-8753-105f-b6a5b8234ff3@freebsd.org> <20171027150841.GH2566@kib.kiev.ua> <20171027152154.GA31598@spindle.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 18:34:40 -0000 On Fri, Oct 27, 2017 at 07:48:43PM +0200, Michal Meloun wrote: > But there is something what's still missing me. > The rescue binary is statically linked, so whole program have only one > TLS section and full TLS layout is determined by linker. > The problematic structure, tsd_tls, is first one in TLS section group: > > readelf -a /usr/obj/usr/src/rescue/rescue/rescue | grep TLS > 518961: 0000000000000000 2880 TLS GLOBAL DEFAULT 9 __je_tsd_tls > and > > objdump -d -j .tdata /usr/obj/usr/src/rescue/rescue/rescue > 00a832b0 <__je_tsd_tls+0xa832b0>: > a832b0: 00000005 > > but disassembled code expect it at TLS ptr + 0x8 (for code without > JEMALLOC_ALIGNED) or at TLS ptr + 0x10 (for code with JEMALLOC_ALIGNED) > > [without JEMALLOC_ALIGNED] > 7c4d90: e59f0014 ldr r0, [pc, #20] ; 7c4dac > > 7c4d94: e58d0004 str r0, [sp, #4] > 7c4d98: eb031d14 bl 88c1f0 <__aeabi_read_tp> > 7c4d9c: e59dc004 ldr ip, [sp, #4] > 7c4da0: e080000c add r0, r0, ip > 7c4da4: e1a0d00b mov sp, fp > 7c4da8: e8bd8800 pop {fp, pc} > 7c4dac: 00000008 .word 0x00000008 [0x10 for code > with JEMALLOC_ALIGNED] > > so someone other allocates at least one byte from start of TLS and > linker is aware about this. But again, .data is first member of TLS > and tsd_tls is first of .tdata and the 0x5 is value of first member of > tsd_tls structure (.state = tsd_state_uninitialized). > > So who consumes the first bytes in TLS ???? Hack the makefile to pass the -M option to linker, like -Wl,-M >/some/path/file.map. The file.map provides the data about sections assembly.