From owner-svn-src-stable-8@FreeBSD.ORG Tue May 7 19:00:08 2013 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1E284503; Tue, 7 May 2013 19:00:08 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) by mx1.freebsd.org (Postfix) with ESMTP id 9E9DEBFA; Tue, 7 May 2013 19:00:07 +0000 (UTC) Received: from spaceball.andric.com (spaceball.andric.com [IPv6:2001:7b8:3a7:0:204:4bff:fe01:de8a]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 459655C44; Tue, 7 May 2013 21:00:06 +0200 (CEST) Message-ID: <51894F2D.7030708@FreeBSD.org> Date: Tue, 07 May 2013 20:59:57 +0200 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Thunderbird/21.0 MIME-Version: 1.0 To: Julian Elischer Subject: Re: svn commit: r250306 - in stable/8/sys: net sys References: <201305061959.r46JxEUA041105@svn.freebsd.org> <51883923.8050505@freebsd.org> In-Reply-To: <51883923.8050505@freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 May 2013 19:00:08 -0000 On 2013-05-07 01:13, Julian Elischer wrote: > On 5/6/13 12:59 PM, Dimitry Andric wrote: >> Author: dim >> Date: Mon May 6 19:59:13 2013 >> New Revision: 250306 >> URL: http://svnweb.freebsd.org/changeset/base/250306 >> >> Log: >> MFC r215137: >> >> Revert r103230, which depended on ld preserving the __start_xxx and >> __stop_xxx symbols for custom sections, even when these were not >> referenced (at link time). This behaviour was changed again in binutils >> commit 0b8ed435c3fe8bd09a08c23920e65bfb03251221. >> >> This time, put the __GLOBL macro definition in cdefs.h, so it can be >> reused in a few other places where it will be needed. > > Is this stuff documented anywhere? If you mean the specifics of , I don't think so. The documentation for the things that use it, are mostly in SYSINIT(9), DECLARE_MODULE(9) and module(9). In any case, the idea is that you tell the compiler and linker to add a few custom sections to the output, which contain metadata, for example to initialize a kernel module. Take the section headers of mpt.ko, for instance: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .hash HASH 000000b4 0000b4 00038c 04 A 2 0 4 [ 2] .dynsym DYNSYM 00000440 000440 000800 10 A 3 1 4 [ 3] .dynstr STRTAB 00000c40 000c40 000792 00 A 0 0 1 [ 4] .rel.dyn REL 000013d4 0013d4 004b80 08 A 2 0 4 [ 5] .text PROGBITS 00005f60 005f60 01258a 00 AX 0 0 16 [ 6] .rodata PROGBITS 000184f0 0184f0 00561d 00 A 0 0 16 [ 7] set_modmetadata_set PROGBITS 0001db10 01db10 000054 00 A 0 0 4 [ 8] set_sysinit_set PROGBITS 0001db64 01db64 000020 00 A 0 0 4 [ 9] set_sysuninit_set PROGBITS 0001db84 01db84 000004 00 A 0 0 4 [10] .dynamic DYNAMIC 0001e000 01e000 000078 08 WA 3 0 4 [11] .got.plt PROGBITS 0001e078 01e078 00000c 04 WA 0 0 4 [12] .data PROGBITS 0001e084 01e084 000478 00 WA 0 0 4 [13] .bss NOBITS 0001e4fc 01e4fc 000310 00 WA 0 0 4 [14] .comment PROGBITS 00000000 01e4fc 0001b3 01 MS 0 0 1 [15] .SUNW_ctf PROGBITS 00000000 01e6b0 0065f7 00 0 0 4 [16] .gnu_debuglink PROGBITS 00000000 024ca7 000014 00 0 0 1 [17] .shstrtab STRTAB 00000000 024cbb 0000bd 00 0 0 1 [18] .symtab SYMTAB 00000000 025098 0018d0 10 19 270 4 [19] .strtab STRTAB 00000000 026968 001e9f 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) The 'set_*' sections are added by the linker_set macros, and are marked as used, so the compiler will not optimize them away. However, in some versions of binutils, the linker still optimizes them away, so we have to resort to inserting assembler directives to force it to keep them. This is what r103230 and r215137 were about. -Dimitry