From: Kwok Cheung Yeung <kcy@codesourcery.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix for PR26702: Emit .size for BSS variables on arm-eabi
Date: Mon, 30 Mar 2015 20:25:00 -0000 [thread overview]
Message-ID: <5519B12F.6000508@codesourcery.com> (raw)
This is a simple patch that ensures that a .size directive is emitted
when space is allocated for a static variable in the BSS on bare-metal
ARM targets. This allows other tools such as GDB to look up the size of
the object correctly.
Before:
$ readelf -s pr26702.o
Symbol table '.symtab' contains 10 entries:
Num: Value Size Type Bind Vis Ndx Name
...
6: 00000000 0 NOTYPE LOCAL DEFAULT 3 static_foo
...
After:
$ readelf -s pr26702.o
Symbol table '.symtab' contains 10 entries:
Num: Value Size Type Bind Vis Ndx Name
...
6: 00000000 4 NOTYPE LOCAL DEFAULT 3 static_foo
...
The testsuite has been run with a i686-pc-linux-gnu hosted
cross-compiler targetted at arm-none-eabi with no regressions.
Kwok
2015-03-30 Kwok Cheung Yeung <kcy@codesourcery.com>
gcc/
PR target/26702
* config/arm/unknown-elf.h (ASM_OUTPUT_ALIGNED_DECL_LOCAL): Emit
size of local.
gcc/testsuite/
PR target/26702
* gcc.target/arm/pr26702.c: New test.
Index: gcc/testsuite/gcc.target/arm/pr26702.c
===================================================================
--- gcc/testsuite/gcc.target/arm/pr26702.c (revision 0)
+++ gcc/testsuite/gcc.target/arm/pr26702.c (revision 0)
@@ -0,0 +1,4 @@
+/* { dg-do compile { target arm*-*-eabi* } } */
+/* { dg-final { scan-assembler "\\.size\[\\t \]+static_foo, 4" } } */
+int foo;
+static int static_foo;
Index: gcc/config/arm/unknown-elf.h
===================================================================
--- gcc/config/arm/unknown-elf.h (revision 447549)
+++ gcc/config/arm/unknown-elf.h (working copy)
@@ -81,6 +81,8 @@
ASM_OUTPUT_ALIGN (FILE, floor_log2 (ALIGN / BITS_PER_UNIT)); \
ASM_OUTPUT_LABEL (FILE, NAME); \
fprintf (FILE, "\t.space\t%d\n", SIZE ? (int)(SIZE) : 1); \
+ fprintf (FILE, "\t.size\t%s, %d\n", \
+ NAME, SIZE ? (int)(SIZE) : 1); \
} \
while (0)
next reply other threads:[~2015-03-30 20:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 20:25 Kwok Cheung Yeung [this message]
2015-04-23 14:51 ` Ramana Radhakrishnan
2015-04-30 7:19 ` Bin.Cheng
2015-04-30 16:56 ` Kwok Cheung Yeung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5519B12F.6000508@codesourcery.com \
--to=kcy@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).