PR gas/20247
* as.h (do_not_pad_sections_to_alignment): New global variable.
* as.c (show_usage): Add --no-pad-sections.
(parse_args): Likewise.
* write.c (size_seg): Skip padding the end of the section if
requested from the command line.
(SUB_SEGMENT_ALIGN): Likewise.
* doc/as.texinfo: Document the new option.
* NEWS: Mention the new feature.
* testsuite/gas/elf/section11.s: New test.
* testsuite/gas/elf/section11.d: New test driver.
* testsuite/gas/elf/elf.exp: Run the new test.
+* Add --no-pad-sections to stop the assembler from padding the end of output
+ sections up to their alignment boundary.
+
* Support for the ARMv8-M architecture has been added to the ARM port. Support
for the ARMv8-M Security and DSP Extensions has also been added to the ARM
port.
* Support for the ARMv8-M architecture has been added to the ARM port. Support
for the ARMv8-M Security and DSP Extensions has also been added to the ARM
port.
fprintf (stream, _("\
-nocpp ignored\n"));
fprintf (stream, _("\
fprintf (stream, _("\
-nocpp ignored\n"));
fprintf (stream, _("\
+ -no-pad-sections do not pad the end of sections to alignment boundaries\n"));
+ fprintf (stream, _("\
-o OBJFILE name the object-file output OBJFILE (default a.out)\n"));
fprintf (stream, _("\
-R fold data section into text section\n"));
-o OBJFILE name the object-file output OBJFILE (default a.out)\n"));
fprintf (stream, _("\
-R fold data section into text section\n"));
OPTION_REDUCE_MEMORY_OVERHEADS,
OPTION_WARN_FATAL,
OPTION_COMPRESS_DEBUG,
OPTION_REDUCE_MEMORY_OVERHEADS,
OPTION_WARN_FATAL,
OPTION_COMPRESS_DEBUG,
- OPTION_NOCOMPRESS_DEBUG
+ OPTION_NOCOMPRESS_DEBUG,
+ OPTION_NO_PAD_SECTIONS /* = STD_BASE + 40 */
/* When you add options here, check that they do
not collide with OPTION_MD_BASE. See as.h. */
};
/* When you add options here, check that they do
not collide with OPTION_MD_BASE. See as.h. */
};
,{"MD", required_argument, NULL, OPTION_DEPFILE}
,{"mri", no_argument, NULL, 'M'}
,{"nocpp", no_argument, NULL, OPTION_NOCPP}
,{"MD", required_argument, NULL, OPTION_DEPFILE}
,{"mri", no_argument, NULL, 'M'}
,{"nocpp", no_argument, NULL, OPTION_NOCPP}
+ ,{"no-pad-sections", no_argument, NULL, OPTION_NO_PAD_SECTIONS}
,{"no-warn", no_argument, NULL, 'W'}
,{"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS}
,{"statistics", no_argument, NULL, OPTION_STATISTICS}
,{"no-warn", no_argument, NULL, 'W'}
,{"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS}
,{"statistics", no_argument, NULL, OPTION_STATISTICS}
case OPTION_NOCPP:
break;
case OPTION_NOCPP:
break;
+ case OPTION_NO_PAD_SECTIONS:
+ do_not_pad_sections_to_alignment = 1;
+ break;
+
case OPTION_STATISTICS:
flag_print_statistics = 1;
break;
case OPTION_STATISTICS:
flag_print_statistics = 1;
break;
150 isn't special; it's just an arbitrary non-ASCII char value. */
#define OPTION_STD_BASE 150
/* The first getopt value for machine-dependent long options.
150 isn't special; it's just an arbitrary non-ASCII char value. */
#define OPTION_STD_BASE 150
/* The first getopt value for machine-dependent long options.
- 190 gives the standard options room to grow. */
-#define OPTION_MD_BASE 190
+ 290 gives the standard options room to grow. */
+#define OPTION_MD_BASE 290
#ifdef DEBUG
#undef NDEBUG
#ifdef DEBUG
#undef NDEBUG
leave lots of padding. */
COMMON int linkrelax;
leave lots of padding. */
COMMON int linkrelax;
+COMMON int do_not_pad_sections_to_alignment;
+
/* TRUE if we should produce a listing. */
extern int listing;
/* TRUE if we should produce a listing. */
extern int listing;
[@b{-K}] [@b{-L}] [@b{--listing-lhs-width}=@var{NUM}]
[@b{--listing-lhs-width2}=@var{NUM}] [@b{--listing-rhs-width}=@var{NUM}]
[@b{--listing-cont-lines}=@var{NUM}] [@b{--keep-locals}]
[@b{-K}] [@b{-L}] [@b{--listing-lhs-width}=@var{NUM}]
[@b{--listing-lhs-width2}=@var{NUM}] [@b{--listing-rhs-width}=@var{NUM}]
[@b{--listing-cont-lines}=@var{NUM}] [@b{--keep-locals}]
+ [@b{--no-pad-sections}]
[@b{-o} @var{objfile}] [@b{-R}]
[@b{--hash-size}=@var{NUM}] [@b{--reduce-memory-overheads}]
[@b{--statistics}]
[@b{-o} @var{objfile}] [@b{-R}]
[@b{--hash-size}=@var{NUM}] [@b{--reduce-memory-overheads}]
[@b{--statistics}]
Set the maximum number of lines printed in a listing for a single line of input
to @var{number} + 1.
Set the maximum number of lines printed in a listing for a single line of input
to @var{number} + 1.
+@item --no-pad-sections
+Stop the assembler for padding the ends of output sections to the alignment
+of that section. The default is to pad the sections, but this can waste space
+which might be needed on targets which have tight memory constraints.
+
@item -o @var{objfile}
Name the object-file output from @command{@value{AS}} @var{objfile}.
@item -o @var{objfile}
Name the object-file output from @command{@value{AS}} @var{objfile}.
* listing:: --listing-XXX to configure listing output
* M:: -M or --mri to assemble in MRI compatibility mode
* MD:: --MD for dependency tracking
* listing:: --listing-XXX to configure listing output
* M:: -M or --mri to assemble in MRI compatibility mode
* MD:: --MD for dependency tracking
+* no-pad-sections:: --no-pad-sections to stop section padding
* o:: -o to name the object file
* R:: -R to join data and text sections
* statistics:: --statistics to see statistics about assembly
* o:: -o to name the object file
* R:: -R to join data and text sections
* statistics:: --statistics to see statistics about assembly
This feature is used in the automatic updating of makefiles.
This feature is used in the automatic updating of makefiles.
+@node no-pad-sections
+@section Output Section Padding
+@kindex --no-pad-sections
+@cindex output section padding
+Normally the assembler will pad the end of each output section up to its
+alignment boundary. But this can waste space, which can be significant on
+memory constrained targets. So the @option{--no-pad-sections} option will
+disable this behaviour.
+
@node o
@section Name the Object File: @option{-o}
@node o
@section Name the Object File: @option{-o}
(@pxref{Include,,@code{.include}}). You can use the @sc{gnu} C compiler driver
to get other ``CPP'' style preprocessing by giving the input file a
@samp{.S} suffix. @xref{Overall Options, ,Options Controlling the Kind of
(@pxref{Include,,@code{.include}}). You can use the @sc{gnu} C compiler driver
to get other ``CPP'' style preprocessing by giving the input file a
@samp{.S} suffix. @xref{Overall Options, ,Options Controlling the Kind of
-Output, gcc.info, Using GNU CC} .
+Output, gcc info, Using GNU CC}.
Excess whitespace, comments, and character constants
cannot be used in the portions of the input text that are not
Excess whitespace, comments, and character constants
cannot be used in the portions of the input text that are not
run_dump_test "section8"
run_dump_test "section9"
run_dump_test "section10"
run_dump_test "section8"
run_dump_test "section9"
run_dump_test "section10"
+ run_dump_test "section11"
run_dump_test "dwarf2-1"
run_dump_test "dwarf2-2"
run_dump_test "dwarf2-3"
run_dump_test "dwarf2-1"
run_dump_test "dwarf2-2"
run_dump_test "dwarf2-3"
--- /dev/null
+#as: --no-pad-sections
+#readelf: -S --wide
+#name: Disabling section padding
+# The RX port uses non standard section names.
+#skip: rx-*-*
+
+#...
+ \[ .\] .text[ ]+PROGBITS[ ]+0+00 0+[0-9a-f]+ 0+0(1|4|5) 00 AX 0 0 16
+#...
+ \[ .\] .data[ ]+PROGBITS[ ]+0+00 0+[0-9a-f]+ 0+01 00 WA 0 0 16
+#...
+ \[ .\] .bss[ ]+NOBITS[ ]+0+00 0+[0-9a-f]+ 0+01 00 WA 0 0 16
+#pass
--- /dev/null
+.section .bss
+.balign 16
+.skip 1
+
+
+.data
+.balign 16
+.skip 1
+
+
+.text
+.balign 16
+.skip 1
+
x = bfd_set_section_flags (abfd, sec, flags);
gas_assert (x);
x = bfd_set_section_flags (abfd, sec, flags);
gas_assert (x);
- newsize = md_section_align (sec, size);
+ /* If permitted, allow the backend to pad out the section
+ to some alignment boundary. */
+ if (do_not_pad_sections_to_alignment)
+ newsize = size;
+ else
+ newsize = md_section_align (sec, size);
x = bfd_set_section_size (abfd, sec, newsize);
gas_assert (x);
x = bfd_set_section_size (abfd, sec, newsize);
gas_assert (x);
}
/* Finish the subsegments. After every sub-segment, we fake an
}
/* Finish the subsegments. After every sub-segment, we fake an
- ".align ...". This conforms to BSD4.2 brane-damage. We then fake
+ ".align ...". This conforms to BSD4.2 brain-damage. We then fake
".fill 0" because that is the kind of frag that requires least
thought. ".align" frags like to have a following frag since that
makes calculating their intended length trivial. */
".fill 0" because that is the kind of frag that requires least
thought. ".align" frags like to have a following frag since that
makes calculating their intended length trivial. */
code-bearing sections. */
#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
(!(FRCHAIN)->frch_next && subseg_text_p (SEG) \
code-bearing sections. */
#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) \
(!(FRCHAIN)->frch_next && subseg_text_p (SEG) \
+ && !do_not_pad_sections_to_alignment \
? get_recorded_alignment (SEG) \
: 0)
#else
? get_recorded_alignment (SEG) \
: 0)
#else