From patchwork Sun Mar 25 07:10:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 890617 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4087jj06fNz9s0b for ; Sun, 25 Mar 2018 18:11:21 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IImltaKh"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4087jh5MrkzF1t8 for ; Sun, 25 Mar 2018 18:11:20 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IImltaKh"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::234; helo=mail-pf0-x234.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IImltaKh"; dkim-atps=neutral Received: from mail-pf0-x234.google.com (mail-pf0-x234.google.com [IPv6:2607:f8b0:400e:c00::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4087jX69SdzF1sX for ; Sun, 25 Mar 2018 18:11:12 +1100 (AEDT) Received: by mail-pf0-x234.google.com with SMTP id f15so572073pfn.0 for ; Sun, 25 Mar 2018 00:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xTQ1qP94Hhv98WYbTI9eiisShrkwUoRIj5/Aqta0ldE=; b=IImltaKhwtYAd0VncBYAYpj9NsHpbcMMzJO240TqW9ghdBxlo6lIuGZHdP5o7XcLts VD+Oc3vurN6GcWQsQSdL2bzq84A2awcIZWZnk3DRxjnAmW7iEfOWI7CJW2L9P7RTqLwO SCHkLR2JdF1UHvBXw2OjMh86DOj1P7u1bx2/lEmPrBtHsOc2gePSbTb/oD9nuU6PhkQ9 AIhUv482lfpvzFRkG5u7Q75jblYMu2DZDiC/uUpMPJAaZxtEEdEyuDX9XP6DQobhgQwr RViI0pJugqyDsJiHGOagO6AOPzrNY31c5EulfrS4RPPU0Y/4UcBDCay6jgdSAp8o59Xz 1RaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xTQ1qP94Hhv98WYbTI9eiisShrkwUoRIj5/Aqta0ldE=; b=gd7hxTZALjqsVgEU+Z1aoF2rhLoD3lfCtTQWrkGhxyhp8vMy6dbP+SJ8FYpfFV3Y9h iTo5QHIqIsjVYMkyoKADP2qjCfa8Nk+3KtYSO0e7I8qEiVwZzagLuxCYZpOKMML9OE6W Qz2VZx00ozppE41Xjmftcaur5nDey9D3nD2NuxK3x7k+3RONzaqPIZISwAGzNlK3djXY 6LAAUbkqYEmW/BvoLzGI2CIVw9LG1GqsIdIttkmF1hAruopflIAfrjzOb7NToEpyGFHX t1P0gZonUR2JajjTiWufd0JpHhdgfCofEvHJqn7qVtS2ph/NUuXu9nvXG5/Wtaq7Yck/ DvgQ== X-Gm-Message-State: AElRT7FTjrqAyLUfQa6XV6KqVfkM+7KRFnonmZtL8udIPAwXXVdIDlgV MrotZNVuWwAHOGn9u5aWZyZ+uQ== X-Google-Smtp-Source: AG47ELvxg3sOBhAHY/rX7+JMPKEP0nKM2V5ElglVzZZP0LGmcnM0Ga1Bl6p+aVO6FJWm+B78UzBwoA== X-Received: by 10.101.96.205 with SMTP id r13mr16501841pgv.427.1521961869669; Sun, 25 Mar 2018 00:11:09 -0700 (PDT) Received: from roar.au.ibm.com (115-64-218-172.tpgi.com.au. [115.64.218.172]) by smtp.gmail.com with ESMTPSA id c129sm26185842pfa.105.2018.03.25.00.11.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Mar 2018 00:11:08 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sun, 25 Mar 2018 17:10:57 +1000 Message-Id: <20180325071057.15646-1-npiggin@gmail.com> X-Mailer: git-send-email 2.16.1 Subject: [Skiboot] [RFC PATCH] build: link with --orphan-handling=warn, explicitly place orphan sections X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The linker can warn when the linker script does not explicitly place all sections. These orphan sections are placed according to heuristics, which may not always be desirable. This patch enables orphan section warnings for the final link, and attempts to do something sane with the orphan sections we currently have. This should be at least 2 patches, but I'll just ask for comments first. Thanks, Nick --- Makefile.main | 3 ++- skiboot.lds.S | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/Makefile.main b/Makefile.main index 96836384..3b69f4f5 100644 --- a/Makefile.main +++ b/Makefile.main @@ -126,7 +126,8 @@ LDFLAGS += -Wl,-pie LDFLAGS += -Wl,-Ttext-segment,$(LD_TEXT) -Wl,-N -Wl,--build-id=none LDFLAGS += -Wl,--no-multi-toc LDFLAGS += -mcpu=power7 -mbig-endian -Wl,--oformat,elf64-powerpc -LDFLAGS_FINAL = $(LDFLAGS) -Wl,--whole-archive +LDFLAGS_FINAL = $(LDFLAGS) -Wl,--whole-archive -Wl,--orphan-handling=warn + LDRFLAGS=-melf64ppc # Debug stuff #LDFLAGS += -Wl,-v -Wl,-Map,foomap diff --git a/skiboot.lds.S b/skiboot.lds.S index a6e71077..edadd93c 100644 --- a/skiboot.lds.S +++ b/skiboot.lds.S @@ -17,6 +17,49 @@ #include #include +/* Debug sections from binutils `ld --verbose` */ + +#define DEBUG_SECTIONS \ + /* Stabs debugging sections. */ \ + .stab 0 : { *(.stab) } \ + .stabstr 0 : { *(.stabstr) } \ + .stab.excl 0 : { *(.stab.excl) } \ + .stab.exclstr 0 : { *(.stab.exclstr) } \ + .stab.index 0 : { *(.stab.index) } \ + .stab.indexstr 0 : { *(.stab.indexstr) } \ + .comment 0 : { *(.comment) } \ + /* DWARF debug sections. \ + Symbols in the DWARF debugging sections are relative to the beginning \ + of the section so we begin them at 0. */ \ + /* DWARF 1 */ \ + .debug 0 : { *(.debug) } \ + .line 0 : { *(.line) } \ + /* GNU DWARF 1 extensions */ \ + .debug_srcinfo 0 : { *(.debug_srcinfo) } \ + .debug_sfnames 0 : { *(.debug_sfnames) } \ + /* DWARF 1.1 and DWARF 2 */ \ + .debug_aranges 0 : { *(.debug_aranges) } \ + .debug_pubnames 0 : { *(.debug_pubnames) } \ + /* DWARF 2 */ \ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } \ + .debug_abbrev 0 : { *(.debug_abbrev) } \ + .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } \ + .debug_frame 0 : { *(.debug_frame) } \ + .debug_str 0 : { *(.debug_str) } \ + .debug_loc 0 : { *(.debug_loc) } \ + .debug_macinfo 0 : { *(.debug_macinfo) } \ + /* SGI/MIPS DWARF 2 extensions */ \ + .debug_weaknames 0 : { *(.debug_weaknames) } \ + .debug_funcnames 0 : { *(.debug_funcnames) } \ + .debug_typenames 0 : { *(.debug_typenames) } \ + .debug_varnames 0 : { *(.debug_varnames) } \ + /* DWARF 3 */ \ + .debug_pubtypes 0 : { *(.debug_pubtypes) } \ + .debug_ranges 0 : { *(.debug_ranges) } \ + /* DWARF Extension. */ \ + .debug_macro 0 : { *(.debug_macro) } \ + .debug_addr 0 : { *(.debug_addr) } + ENTRY(boot_entry); SECTIONS { @@ -55,7 +98,7 @@ SECTIONS _stext = .; .text : { *(.text*) - *(.sfpr) + *(.sfpr .glink) } _etext = .; @@ -134,10 +177,15 @@ SECTIONS *(.rela*) __rela_dyn_end = .; } + .plt : { *(.plt) *(.iplt) } - .hash : { *(.hash) } - .dynsym : { *(.dynsym) } - .dynstr : { *(.dynstr) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } . = ALIGN(0x10); .sym_map : { @@ -151,12 +199,15 @@ SECTIONS _sbss = .; .bss : { + *(.dynbss) *(.bss*) } . = ALIGN(0x10000); _ebss = .; _end = .; + DEBUG_SECTIONS + /* Optional kernel image */ . = ALIGN(0x10000); .builtin_kernel : { @@ -167,6 +218,8 @@ SECTIONS /* Discards */ /DISCARD/ : { + *(.note.GNU-stack) + *(.eh_frame) *(.comment) *(.interp) }