Hello toolchain people,
I created a patch on top of upstream binutils for a feature I need which
should be universally useful as well. Now I have 3 questions for you:
1) Does it look sane enough?
2) If so, could you integrate it in the Linaro release?
3) Would you be willing to promote it upstream?
Comments appreciated.
Here's the patch:
----- >8
Subject: [PATCH] gas: introduce section name substitution support
When gas is invoked with --sectname-subst, the occurrence of %S in a section
name will be substituted by the name of the current section. For example:
.macro exception_code
.pushsection %S.exception
[exception code here]
.popsection
.endm
.text
[code]
exception_code
[...]
.section .init
[init code]
exception_code
[...]
In the first exception_code invocation the .text.exception section is
created while in the second invocation it is the .init.exception section
that is created. This is useful e.g. to discriminate between anciliary
sections that are tied to .init code and can be discarded at run time when
initialization is over vs anciliary sections tied to .text sections that
need to stay resident.
This would also allow for actually omitting __exit sections from the Linux
kernel binary when modules are configured in even when exit marked code
generates exception table entries.
Signed-off-by: Nicolas Pitre <nico(a)linaro.org>
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 57fc30a..0189bb2 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2015-06-03 Nicolas Pitre <nico(a)linaro.org>
+
+ * as.c (show_usage): Document --sectname-subst.
+ (parse_args): Add --sectname-subst.
+ * as.h (flag_sectname_subst): New.
+ * config/obj-elf.c (obj_elf_section_name): Add %S substitution.
+ * doc/as.texinfo: Document it.
+
2015-06-03 Matthew Wahab <matthew.wahab(a)arm.com>
* config/tc-arm.c (arm_archs): Add "armv8.1-a".
diff --git a/gas/as.c b/gas/as.c
index 2a8923f..fecfcd2 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -284,6 +284,8 @@ Options:\n\
fprintf (stream, _("\
--size-check=[error|warning]\n\
ELF .size directive check (default --size-check=error)\n"));
+ fprintf (stream, _("\
+ --sectname-subst enable section name substitution sequences\n"));
#endif
fprintf (stream, _("\
-f skip whitespace and comment preprocessing\n"));
@@ -447,6 +449,7 @@ parse_args (int * pargc, char *** pargv)
OPTION_EXECSTACK,
OPTION_NOEXECSTACK,
OPTION_SIZE_CHECK,
+ OPTION_SECTNAME_SUBST,
OPTION_ALTERNATE,
OPTION_AL,
OPTION_HASH_TABLE_SIZE,
@@ -481,6 +484,7 @@ parse_args (int * pargc, char *** pargv)
,{"execstack", no_argument, NULL, OPTION_EXECSTACK}
,{"noexecstack", no_argument, NULL, OPTION_NOEXECSTACK}
,{"size-check", required_argument, NULL, OPTION_SIZE_CHECK}
+ ,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
#endif
,{"fatal-warnings", no_argument, NULL, OPTION_WARN_FATAL}
,{"gdwarf-2", no_argument, NULL, OPTION_GDWARF2}
@@ -848,6 +852,10 @@ This program has absolutely no warranty.\n"));
else
as_fatal (_("Invalid --size-check= option: `%s'"), optarg);
break;
+
+ case OPTION_SECTNAME_SUBST:
+ flag_sectname_subst = 1;
+ break;
#endif
case 'Z':
flag_always_generate_output = 1;
diff --git a/gas/as.h b/gas/as.h
index 6de319e..635b2c5 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -589,6 +589,9 @@ COMMON enum
size_check_warning
}
flag_size_check;
+
+/* If section name substitution sequences should be honored */
+COMMON int flag_sectname_subst;
#endif
#ifndef DOLLAR_AMBIGU
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 4d7a8a7..78dc6d9 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -917,6 +917,27 @@ obj_elf_section_name (void)
name = (char *) xmalloc (end - input_line_pointer + 1);
memcpy (name, input_line_pointer, end - input_line_pointer);
name[end - input_line_pointer] = '\0';
+
+ while (flag_sectname_subst)
+ {
+ char *subst = strchr (name, '%');
+ if (subst && subst[1] == 'S')
+ {
+ int oldlen = strlen (name);
+ int substlen = strlen (now_seg->name);
+ int newlen = oldlen - 2 + substlen;
+ char *newname = (char *) xmalloc (newlen + 1);
+ int headlen = subst - name;
+ memcpy (newname, name, headlen);
+ strcpy (newname + headlen, now_seg->name);
+ strcat (newname + headlen, subst + 2);
+ xfree (name);
+ name = newname;
+ }
+ else
+ break;
+ }
+
#ifdef tc_canonicalize_section_name
name = tc_canonicalize_section_name (name);
#endif
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index 5710e1c..be13b6a 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -6259,6 +6259,36 @@ For ELF targets, the @code{.section} directive is used like this:
.section @var{name} [, "@var{flags}"[, @@@var{type}[,@var{flag_specific_arguments}]]]
@end smallexample
+@cindex --sectname-subst
+If the @samp{--sectname-subst} command-line option is provided, the @var{name}
+argument may contain a substitution sequence. Only @code{%S} is supported
+at the moment, and substitutes the current section name. For example:
+
+@smallexample
+.macro exception_code
+.section %S.exception
+[exception code here]
+.previous
+.endm
+
+.text
+[code]
+exception_code
+[...]
+
+.section .init
+[init code]
+exception_code
+[...]
+@end smallexample
+
+The two @code{exception_code} invocations above would create the
+(a)code{.text.exception} and @code{.init.exception} sections respectively.
+This is useful e.g. to discriminate between anciliary sections that are
+tied to setup code to be discarded after use from anciliary sections that
+need to stay resident without having to define two @code{exception_code}
+macros just for that purpose.
+
The optional @var{flags} argument is a quoted string which may contain any
combination of the following characters:
@table @code
Nicolas
* 1 day off (2/10)
== Progress ==
* Neon intrinsics tests
- committed last batch of tests
- need to think about tests for vget_lane which are still missing,
but not high priority
* linaro-gcc-5.1-2015.06 snapshot (4/10)
- committed branch merge with upstream gcc-5-branch
- prepared snapshot & updated release scripts
* Upstream maintenance (1/10)
- backported a fix from Michael to 4.8 and 4.9 branches
- backported fix for PR62308 to 4.9 branch
- most of the time spent on bootstrapping on aarch64 HW
- started looking at some recent new tests having trouble dealing
with some multilib variants
* Misc (3/10)
- meetings, conf-calls, emails, ...
== Next ==
* linaro-gcc-5.1-2015.06 snapshot
- build release notes
- create a proper tag
* backports, release, validation:
- update doc according to our new process
* validation:
- take unstable tests into account
* upstream maintenance:
- check recent regressions
== Progress ==
* Maintenance (CARD-1833 2/10)
- Initial work on ADD<->SUB for negative imm in asm
* Buildbots (CARD-1823 6/10)
- Adding test-suite to CMake buildbot (D10244)
- Bisecting broken self-hosting vfp3 bots
* Background (2/10)
- Code review, meetings, discussions, etc.
- Some more meetings about infrastructure...
- LLVM status and plan for next half
* Sprint Week in Grenoble
== Plan ==
* Continue with CMake LNT changes
* Carry on with ADD/SUB change
* Revive ASM warnings discussion
Holiday [2/10]
Benchmark Automation - TCWG-360 [4/10]
* Learned about central Jenkins instance
* Considered ways of integrating benchmark scripts with said instance
* Considered alternative way for benchmark scripts to interoperate with LAVA
Misc [4/10]
* Large mail backlog
* Travel prep
=Plan=
Team sprint
# Progress #
* Linaro GDB [4/10]
** TCWG-805, aarch64 native debugging multi-arch support.
aarch64 native gdb is able to debug arm program now, but with some
problems on coredump. Patches are not posted.
** Give my input on GDB kernel awareness too, and the proposal finally
is posted upstream.
* FSF GDB [1/10]
** Patches review.
* Misc [5/10]
** Attend an internal ARM Debug/Tracing summit.
** Prepare for the France travel.
# Plan #
* Sprint in Grenoble.
--
Yao
Hi Linaro Toolchain Group,
I am trying to build a cross-native toolchain for AARCH64 using ABE build
framework.
By cross native I mean that toolchain will be build on 0x86 (Red hat
Santiago 6.4), it will run on AARCH64 (Juno) and
will produce binaries to be run on AARCH64 (Juno)
(If I am not mistaked) --build=0x86, --host=AARCH64, --target=AARCH64
Steps followed:
1. I built a cross toolchain first
../abe/configure
../abe/abe.sh --target aarch64-linux-gnu --build all --release 2015.05.29
--tarbin --disable update
2. Added the above cross toolchain (bin path) in the PATH
3. To build to cross-native
../abe/configure
../abe/abe.sh --host aarch64-linux-gnu --target aarch64-linux-gnu --build
all --release 2015.06.01.native --tarbin --disable update
But after some time, I got following error and compilation hanged.
make: Leaving directory
`/home/user_name/vpathak/build_abe/builds/aarch64-linux-gnu/aarch64-linux-gnu/gcc.git~linaro-4.9-branch-stage1'
RUN: copy_gcc_libs_to_sysroot
"/home/user_name/vpathak/build_abe/builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
--sysroot=/home/user_name/vpathak/build_abe/sysroots/aarch64-linux-gnu"
/home/user_name/vpathak/abe/lib/make.sh: line 962:
./builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc: cannot
execute binary file
Am I missing something ? Please help.
However with the following hack in the abe, I am able to compile
cross-native toolchain for aarch64-linux-gnu.
In the abe code base:
-------------------------------------------------------------------------------------------------------
lib/make.sh
Function copy_gcc_libs_to_sysroot()
gcc_exe="`find -name ${target}-gcc`"
- libgcc="`${gcc_exe} -print-file-name=${libgcc}`"
+ #libgcc="`${gcc_exe} -print-file-name=${libgcc}`"
+
libgcc="/home/user_name/vpathak/build_abe/builds/destdir/aarch64-linux-gnu/lib/gcc/aarch64-linux-gnu/4.9.3/libgcc.a"
Since './builds/destdir/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc' is
native toolchain it will not run on 0x86. Thus libgcc will be empty.
Therefore I hard-coded libgcc path.
-------------------------------------------------------------------------------------------------------
I had to disable gdb compilation. This error I faced while compiling
cross-native compilation only.
Cross compilation is successful on the same 0x86 machine.
checking for library containing waddstr... no
configure: error: no enhanced curses library found; disable TUI
make: *** [configure-gdb] Error 1
make: Leaving directory
`/home/user_name/vpathak/build_abe/builds/aarch64-linux-gnu/aarch64-linux-gnu/binutils-gdb.git~linaro_gdb-7.8-branch-gdb'
WARNING: Make had failures!
ERROR (#159): build_all (Failed building .)
hacked patch
--- a/lib/make.sh
+++ b/lib/make.sh
@@ -31,10 +31,10 @@ build_all()
# to rebuilt the sysroot.
local builds="infrastructure binutils libc stage2 gdb"
else
- local builds="infrastructure binutils stage1 libc stage2 gdb"
+ local builds="infrastructure binutils stage1 libc stage2"
fi
if test "`echo ${target} | grep -c -- -linux-`" -eq 1; then
- local builds="${builds} gdbserver"
+ local builds="${builds}"
fi
---------------------------------------------------------------------------------------------------------------
Thanks.
--
with regards,
Virendra Kumar Pathak
Hi Linaro Toolchain Group,
Is there any tool for checking coding style of the patches submitted to the
Linaro Toolchain ?
In other word is there any equivalent of Linux checkpatch.pl in Linaro
Toolchain (GCC, Binutils etc) ?
If yes, please let me know.
If not, then in general how people check the coding style of the patches
they submit to Linaro Toolchain (GCC, Binutils etc).
I assume manual inspection (line by line) may be very tedious thing to do.
Thanks.
--
with regards,
Virendra Kumar Pathak
== Progress ==
* Upstream GCC (8/10)
- TCWG-486 - Optimize Constant Uses in Loops.
- Jeff reviewed it and asked for some minor changes
- Rebased and redid full testing and posted it
- TCWG-555 - Complete re-write of widening pass based on review comments
- Getting ready to post for review
* Misc (2/10)
- Reading TACT User Manual
- gcc-patches, gcc-bugs list
- Meetings
== Plan ==
- Continue with gcc stage1 activities