From owner-svn-src-stable@FreeBSD.ORG Tue May 7 20:12:45 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C08A6D2; Tue, 7 May 2013 20:12:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id 9352AF7B; Tue, 7 May 2013 20:12:45 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 0AC31B94A; Tue, 7 May 2013 16:12:45 -0400 (EDT) From: John Baldwin To: Dimitry Andric Subject: Re: svn commit: r250306 - in stable/8/sys: net sys Date: Tue, 7 May 2013 16:12:34 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <201305061959.r46JxEUA041105@svn.freebsd.org> <51883923.8050505@freebsd.org> <51894F2D.7030708@FreeBSD.org> In-Reply-To: <51894F2D.7030708@FreeBSD.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201305071612.34947.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 07 May 2013 16:12:45 -0400 (EDT) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Julian Elischer , svn-src-stable-8@freebsd.org X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 May 2013 20:12:45 -0000 On Tuesday, May 07, 2013 2:59:57 pm Dimitry Andric wrote: > 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. You can use linker sets in userland as well. I used them in mfiutil and mptutil to build nested command tables. I've also used linker sets to build lists of unit tests in kernel modules. -- John Baldwin