From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56887 invoked by alias); 4 Oct 2016 01:20:33 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 56877 invoked by uid 89); 4 Oct 2016 01:20:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=0xc, 12th, Storage, readelf X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Oct 2016 01:20:31 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 956608B13F; Tue, 4 Oct 2016 01:20:30 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u941KQ7v006866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 3 Oct 2016 21:20:29 -0400 Date: Tue, 04 Oct 2016 01:20:00 -0000 From: Jan Kratochvil To: =?iso-2022-jp?B?GyRCSmlFX048GyhC?= Cc: gdb@sourceware.org Subject: Re: How to get value of gs:0xc with LTS note in coredump? Message-ID: <20161004012026.GA30611@host1.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.0 (2016-08-17) X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00005.txt.bz2 On Tue, 04 Oct 2016 02:59:45 +0200, 慕冬亮 wrote: > I have a question about gs and TLS in core dump. When I read the > assembly code from one coredump, there is one memory dereference : > gs:[edx] or gs:0xc. > > I googled gs register and found it points to Thread Local Storage. > However, gs is a selector to GDT and this structure is in the kernel. > And I could not obtain it in coredump. %gs on i386 (and %fs on x86_64) points to pthread_self() which is 'struct pthread *' (if you have glibc debug info available) where at offset 0xc is 'void *self' which is the pthread_self() pointer itself (%gs:0xc is faster to access). > Then I searched all the segments in core dump. I found a note entry > with type NT_386_TLS, length 0x30. Is gs:0xc in this note ? And gs:0xc > is the 12th element of this note entry? Yes, pthread_self() is coincidentally also the value of %gsbase (%fsbase on x86_64) but GDB cannot show that register, in a core file you can see it by "eu-readelf -n" (from elfutils, "readelf -n" from binutils does not show it) as: LINUX 48 386_TLS index: 12, base: 0xf7778800, limit: 0x000fffff, flags: 0x00000051 ^^^^^^^^^^=pthread_self() Jan