From patchwork Thu Apr 11 20:55:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 1084281 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) 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="jPEA1mHS"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44gCxC0s7Gz9s47 for ; Fri, 12 Apr 2019 06:56:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 504BF23543; Thu, 11 Apr 2019 20:56:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x03Yu4xTCSv3; Thu, 11 Apr 2019 20:56:06 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 41833229A3; Thu, 11 Apr 2019 20:56:06 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 798FE1BF479 for ; Thu, 11 Apr 2019 20:56:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 720098813A for ; Thu, 11 Apr 2019 20:56:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zZnctbUs3W6R for ; Thu, 11 Apr 2019 20:56:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by hemlock.osuosl.org (Postfix) with ESMTPS id 4E0348811D for ; Thu, 11 Apr 2019 20:56:02 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id j11so5785973lfm.0 for ; Thu, 11 Apr 2019 13:56:02 -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=81UbPP+iFmtTx5RKtcgDECQWS0V3DHFL5qVbL0E4SpI=; b=jPEA1mHSy7zt0D2kFJUFwmIGDA6sNSNdCYkWJdBUAa+rPsgS1W+BYKUjS/89Y1q22P w0x2ltG5TRn6uQRNIAPp32RmGeM+vh7JKQUVtQ8X+juQ8NlQI0Hewios4nSGtctSAhr6 xJPQLGI2HwzY+ZV7Hgrqw/5DLgYSlW0BaZaqvdGuq7POKMX7Xh9OrEyEE+95HCWG+W3F 9K/962ucfbnaibnajhB3UZoPRx70lom/Um4yO1TjSwDJ6IBt7pqUJVEb+EEzxNXUPUOP BAarym6GqLsc5e1JIdPAWTdA6V+6xPfOlIeNBmvAhaFLVZXvE6Dbwz7qoersLbA6SiGp iQoQ== 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=81UbPP+iFmtTx5RKtcgDECQWS0V3DHFL5qVbL0E4SpI=; b=W2r2tgy7ikTW5m/6vticx+zQv8hPLkww83x7yH4Psx+8NR99cuxl2qqqCmPgpVMWRC CDKzH0kGDVA+1SMgk4g1iPhi+eTzn0HOotXkIKAGwoWTP7QbAJBvtNG1CiRZPG3OSK+L 6kmGUOJU9+sB8uzO4vT+TbjcQMlyxnYxRt6Z3+T4GowzRip+EO3oxQoBHj06wn9F4ykV R1fqZg8z6XkpCDA0jF881HCMhb7bJFEW9Nm6DA3sNaUAgCYhFNg11x2iHPQ65O0LgyVV QATrqNb72F5W+xX3OKVLALBzkmcHzRalJGHCQ2gZpmjGJmKGUf+NOdpHwt0O/n2JBDeG nakw== X-Gm-Message-State: APjAAAV1erFMss9O6HR02fUFg3jOXAGJapdj0yuzHL99Ef1j6chkHYj4 gBVtQE92jqxcsYegRFzNSjIUi9bz X-Google-Smtp-Source: APXvYqyoPKppJwYgjuoxr3k2202CXrt+gnOWoomz7twGFvZabo34jImRF1Sxz17qNKu3rji65OEXSA== X-Received: by 2002:ac2:485a:: with SMTP id 26mr2118400lfy.128.1555016160080; Thu, 11 Apr 2019 13:56:00 -0700 (PDT) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id n2sm7652965lfe.71.2019.04.11.13.55.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Apr 2019 13:55:59 -0700 (PDT) From: Max Filippov To: buildroot@uclibc.org Date: Thu, 11 Apr 2019 13:55:49 -0700 Message-Id: <20190411205549.7259-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 Subject: [Buildroot] [PATCH] package/binutils: fix loops relaxation in bare sections X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Petazzoni MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The commit 197b5f9d1c23 ("package/binutils: fix loops relaxation in xtensa gas") changed the way loop opcodes are relaxed resulting in build failures in hand-made assembly code that has loops in sections without .literal_position pseudo op or equivalent construct. This e.g. breaks xtensa linux kernel build. Fix that by adding literal position to the beginning of every section. Fixes: 197b5f9d1c23 ("package/binutils: fix loops relaxation in xtensa gas") Signed-off-by: Max Filippov --- ...as-put-.literal_position-at-section-start.patch | 96 ++++++++++++++++++++++ ...as-put-.literal_position-at-section-start.patch | 96 ++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 package/binutils/2.31.1/0017-xtensa-gas-put-.literal_position-at-section-start.patch create mode 100644 package/binutils/2.32/0005-xtensa-gas-put-.literal_position-at-section-start.patch diff --git a/package/binutils/2.31.1/0017-xtensa-gas-put-.literal_position-at-section-start.patch b/package/binutils/2.31.1/0017-xtensa-gas-put-.literal_position-at-section-start.patch new file mode 100644 index 000000000000..b4bbc27b3742 --- /dev/null +++ b/package/binutils/2.31.1/0017-xtensa-gas-put-.literal_position-at-section-start.patch @@ -0,0 +1,96 @@ +From 471702ac4a57878a06e8167f063274cf413e548d Mon Sep 17 00:00:00 2001 +From: Max Filippov +Date: Mon, 8 Apr 2019 13:47:18 -0700 +Subject: [PATCH] xtensa: gas: put .literal_position at section start + +Provide literal position at the beginning of each section for literal +space reserved by relaxations when text-section-literals or +auto-litpools options are used. Remove code that adds fill frag to the +literal section for every .literal_position directive to avoid creation +of empty literal sections. + +Fix auto-litpools tests that got literal pool address changes. + +gas/ +2019-04-11 Max Filippov + + * config/tc-xtensa.c (xtensa_is_init_fini): Add declaration. + (xtensa_mark_literal_pool_location): Don't add fill frag to literal + section that records literal pool location. + (md_begin): Call xtensa_mark_literal_pool_location when text + section literals or auto litpools are used. + (xtensa_elf_section_change_hook): Call + xtensa_mark_literal_pool_location when text section literals or + auto litpools are used, there's no literal pool location defined + for the current section and it's not .init or .fini. + +Signed-off-by: Max Filippov +--- + gas/config/tc-xtensa.c | 22 +++++++++------------- + 1 file changed, 9 insertions(+), 13 deletions(-) + +diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c +index 0cc06361cf6f..6a80e76fed8c 100644 +--- a/gas/config/tc-xtensa.c ++++ b/gas/config/tc-xtensa.c +@@ -497,6 +497,7 @@ static fixS *xg_append_jump (fragS *fragP, symbolS *sym, offsetT offset); + static void xtensa_maybe_create_literal_pool_frag (bfd_boolean, bfd_boolean); + static bfd_boolean auto_litpools = FALSE; + static int auto_litpool_limit = 0; ++static bfd_boolean xtensa_is_init_fini (segT seg); + + /* Alignment Functions. */ + +@@ -4797,7 +4798,6 @@ xtensa_mark_literal_pool_location (void) + { + /* Any labels pointing to the current location need + to be adjusted to after the literal pool. */ +- emit_state s; + fragS *pool_location; + + if (use_literal_section) +@@ -4818,19 +4818,7 @@ xtensa_mark_literal_pool_location (void) + RELAX_LITERAL_POOL_END, NULL, 0, NULL); + xtensa_set_frag_assembly_state (frag_now); + +- /* Now put a frag into the literal pool that points to this location. */ + set_literal_pool_location (now_seg, pool_location); +- xtensa_switch_to_non_abs_literal_fragment (&s); +- frag_align (2, 0, 0); +- record_alignment (now_seg, 2); +- +- /* Close whatever frag is there. */ +- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL); +- xtensa_set_frag_assembly_state (frag_now); +- frag_now->tc_frag_data.literal_frag = pool_location; +- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL); +- xtensa_restore_emit_state (&s); +- xtensa_set_frag_assembly_state (frag_now); + } + + +@@ -5334,6 +5322,9 @@ md_begin (void) + /* Set up the assembly state. */ + if (!frag_now->tc_frag_data.is_assembly_state_set) + xtensa_set_frag_assembly_state (frag_now); ++ ++ if (!use_literal_section) ++ xtensa_mark_literal_pool_location (); + } + + +@@ -5933,6 +5924,11 @@ xtensa_elf_section_change_hook (void) + /* Set up the assembly state. */ + if (!frag_now->tc_frag_data.is_assembly_state_set) + xtensa_set_frag_assembly_state (frag_now); ++ ++ if (!use_literal_section ++ && seg_info (now_seg)->tc_segment_info_data.literal_pool_loc == NULL ++ && !xtensa_is_init_fini (now_seg)) ++ xtensa_mark_literal_pool_location (); + } + + +-- +2.11.0 + diff --git a/package/binutils/2.32/0005-xtensa-gas-put-.literal_position-at-section-start.patch b/package/binutils/2.32/0005-xtensa-gas-put-.literal_position-at-section-start.patch new file mode 100644 index 000000000000..b4bbc27b3742 --- /dev/null +++ b/package/binutils/2.32/0005-xtensa-gas-put-.literal_position-at-section-start.patch @@ -0,0 +1,96 @@ +From 471702ac4a57878a06e8167f063274cf413e548d Mon Sep 17 00:00:00 2001 +From: Max Filippov +Date: Mon, 8 Apr 2019 13:47:18 -0700 +Subject: [PATCH] xtensa: gas: put .literal_position at section start + +Provide literal position at the beginning of each section for literal +space reserved by relaxations when text-section-literals or +auto-litpools options are used. Remove code that adds fill frag to the +literal section for every .literal_position directive to avoid creation +of empty literal sections. + +Fix auto-litpools tests that got literal pool address changes. + +gas/ +2019-04-11 Max Filippov + + * config/tc-xtensa.c (xtensa_is_init_fini): Add declaration. + (xtensa_mark_literal_pool_location): Don't add fill frag to literal + section that records literal pool location. + (md_begin): Call xtensa_mark_literal_pool_location when text + section literals or auto litpools are used. + (xtensa_elf_section_change_hook): Call + xtensa_mark_literal_pool_location when text section literals or + auto litpools are used, there's no literal pool location defined + for the current section and it's not .init or .fini. + +Signed-off-by: Max Filippov +--- + gas/config/tc-xtensa.c | 22 +++++++++------------- + 1 file changed, 9 insertions(+), 13 deletions(-) + +diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c +index 0cc06361cf6f..6a80e76fed8c 100644 +--- a/gas/config/tc-xtensa.c ++++ b/gas/config/tc-xtensa.c +@@ -497,6 +497,7 @@ static fixS *xg_append_jump (fragS *fragP, symbolS *sym, offsetT offset); + static void xtensa_maybe_create_literal_pool_frag (bfd_boolean, bfd_boolean); + static bfd_boolean auto_litpools = FALSE; + static int auto_litpool_limit = 0; ++static bfd_boolean xtensa_is_init_fini (segT seg); + + /* Alignment Functions. */ + +@@ -4797,7 +4798,6 @@ xtensa_mark_literal_pool_location (void) + { + /* Any labels pointing to the current location need + to be adjusted to after the literal pool. */ +- emit_state s; + fragS *pool_location; + + if (use_literal_section) +@@ -4818,19 +4818,7 @@ xtensa_mark_literal_pool_location (void) + RELAX_LITERAL_POOL_END, NULL, 0, NULL); + xtensa_set_frag_assembly_state (frag_now); + +- /* Now put a frag into the literal pool that points to this location. */ + set_literal_pool_location (now_seg, pool_location); +- xtensa_switch_to_non_abs_literal_fragment (&s); +- frag_align (2, 0, 0); +- record_alignment (now_seg, 2); +- +- /* Close whatever frag is there. */ +- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL); +- xtensa_set_frag_assembly_state (frag_now); +- frag_now->tc_frag_data.literal_frag = pool_location; +- frag_variant (rs_fill, 0, 0, 0, NULL, 0, NULL); +- xtensa_restore_emit_state (&s); +- xtensa_set_frag_assembly_state (frag_now); + } + + +@@ -5334,6 +5322,9 @@ md_begin (void) + /* Set up the assembly state. */ + if (!frag_now->tc_frag_data.is_assembly_state_set) + xtensa_set_frag_assembly_state (frag_now); ++ ++ if (!use_literal_section) ++ xtensa_mark_literal_pool_location (); + } + + +@@ -5933,6 +5924,11 @@ xtensa_elf_section_change_hook (void) + /* Set up the assembly state. */ + if (!frag_now->tc_frag_data.is_assembly_state_set) + xtensa_set_frag_assembly_state (frag_now); ++ ++ if (!use_literal_section ++ && seg_info (now_seg)->tc_segment_info_data.literal_pool_loc == NULL ++ && !xtensa_is_init_fini (now_seg)) ++ xtensa_mark_literal_pool_location (); + } + + +-- +2.11.0 +