Commit Graph

95 Commits

Author SHA1 Message Date
Jan Beulich
af3394d97a ELF: SHF_STRINGS isn't really tied to SHF_MERGE
It's not overly useful without it, but the spec doesn't name any
dependency between the two. People may want to use it for purely
informational purposes, for example. Adjust, in particular, entity size
processing to be engaged if either flag is set, as mandated by the spec.
2024-11-18 11:36:57 +01:00
Andreas Krebbel
a98a6fa2d8 s390: Add arch15 instructions
opcodes/
	* s390-mkopc.c (main) Accept arch15 as CPU string.
	* s390-opc.txt: Add arch15 instructions.

include/
	* opcode/s390.h (enum s390_opcode_cpu_val): Add
	S390_OPCODE_ARCH15.

gas/
	* config/tc-s390.c (s390_parse_cpu): New entry for arch15.
	* doc/c-s390.texi: Document arch15 march option.
	* doc/as.texi: Likewise.
	* testsuite/gas/s390/s390.exp: Run the arch15 related tests.
	* testsuite/gas/s390/zarch-arch15.d: Tests for arch15
	instructions.
	* testsuite/gas/s390/zarch-arch15.s: Likewise.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
2024-10-10 12:09:40 +02:00
Jan Beulich
1264d4a096 gas/doc: adjust an @xref
Old doc tools warn about there not being a . or , following; satisfy
those tools by shortening the line and adding a full stop.
2024-07-31 12:03:23 +02:00
Jan Beulich
0d96d156ac gas: consistently drop trailing whitespace when scrubbing
From especially the checks for the two separator forms it appears to
follow that the construct being touched is about trailing whitespace. In
such a case, considering that for many targets ordinary and line comment
chars overlap, take into account that line comment chars override
ordinary ones in lex[] (logic elsewhere in do_scrub_chars() actually
depends on that ordering, and also accounts for this overriding).

Plus of course IS_NEWLINE() would better also be consulted. Note also
that the DOUBLESLASH_LINE_COMMENTS change should generally have no
effect just yet; it's a prereq for a later change but better fits here.

Leave respective comments as well, and update documentation to correct
which comment form is actually replaced by a single blank (i.e. neither
the ones starting with what {,tc_}comment_chars[] has nor the ones
starting with what line_comment_chars[] has).
2024-07-19 11:54:09 +02:00
Matthieu Longo
05974f2467 gas: minor reformatting in command line help and doc
- help message: add a comma between the short and long option
- as doc:
  - brief summary of how to invoke gas: separate [-w] [-x] on a new line as those
  two options have nothing to do with the warning options.
  - reordering of the warning options to have the same order as the listing.
  - no-warn option description: change an "and" to a "or", as it is either the short
  or long option to use, but not both at the same time.
- remove trailing whitespaces.
2024-07-18 17:02:27 +01:00
Nick Clifton
a790949155 base64: Add support for targets with byte size > octet size.
PR 31964
2024-07-11 12:52:32 +01:00
Nick Clifton
479edf0a6a Add support for a .base64 pseudo-op to gas
PR 31964
2024-07-10 15:01:39 +01:00
Jan Beulich
1e3c814459 gas: extend \+ support to .rept
PR gas/31752

While not quite as macro-like as .irp / .irpc, this perhaps benefits from
supporting \+ even more than those: It allows, where desired, to get away
without maintaining an explicit count variable in source code.

Keep .rep (and custom per-arch uses of s_rept() / do_repeat()) behavior
unaltered.
2024-06-10 09:06:37 +02:00
Nick Clifton
6d267250a9 Fix typo in assembler documentation 2024-05-28 16:34:52 +01:00
Jan Beulich
69cab370cf gas: adjust handling of quotes for .irpc
The present handling of inner double quotes can lead to very strange
diagnostics. Follow one of the two possible interpretations of the doc:
@dots{} referring to possibly multiple white space separated
@var{values}, each of which may be quoted. The original implementation,
prior to 465e561723 ("PR gas/3856"), hints at the other possible
interpretation: When quoted there's only a single @var{values}, with
inner quotes taken as ordinary characters. That, however, seems overall
less useful to me.

While touching the documentation, mirror the (inverse) spelling
correction (@section line inconsistent with actual description) to .irp
as well.
2024-05-24 12:22:54 +02:00
Nick Clifton
83b972fc27 Add new assembler macro pseudo-variable \+ which counts the number of times a macro has been invoked. 2024-05-13 09:56:09 +01:00
Nick Clifton
8c8de179c2 Gas Doc: Update example of how .altmacro affects the interpretation of macro arguments.
PR 31255
2024-04-16 12:06:08 +01:00
Nick Clifton
99daf56f4b Update description of macro keyword argument assignment in assembler documentation.
PR 31255
2024-04-12 16:51:51 +01:00
Jens Remus
dfa4ac9728 s390: Warn when register name type does not match operand
Print a warning message when the register type of a specified register
name does not match with the operand's register type:

operand {#}: expected {access|control|floating-point|general|vector}
  register name [as {base|index} register]

Introduce a s390-specific assembler option "warn-regtype-mismatch"
with the values "strict", "relaxed", and "no" as well as an option
"no-warn-regtype-mismatch" which control whether the assembler
performs register name type checks and generates above warning messages.

warn-regtype-mismatch=strict:
  Perform strict register name type checks.

warn-regtype-mismatch=relaxed:
  Perform relaxed register name type checks, which allow floating-point
  register (FPR) names %f0 to %f15 to be specified as argument to vector
  register (VR) operands and vector register (VR) names %v0 to %v15 to
  be specified as argument to floating-point register (FPR) operands.
  This is acceptable as the FPRs are embedded into the lower halves of
  the VRs. Make "relaxed" the default, as GCC generates assembler code
  using FPR and VR interchangeably, which would cause assembler warnings
  to be generated with "strict".

warn-regtype-mismatch=no:
no-warn-regtype-mismatch:
  Disable any register name type checks.

Tag .insn pseudo mnemonics as such, to skip register name type checks
on those. They need to be skipped, as there do not exist .insn pseudo
mnemonics for every possible operand register type combination. Keep
track of the currently parsed operand number to provide it as reference
in warning messages.

To verify that the introduction of this change does not unnecessarily
affect the compilation of existing code the GNU Binutils, GNU C Library,
and Linux Kernel have been build with the new assembler, verifying that
the assembler did not generate any of the new warning messages.

gas/
	* config/tc-s390.c: Handle new assembler options
	"[no]warn-regtype-mismatch[=strict|relaxed|no". Annotate
	parsed register expressions with register type. Keep track of
	operand number being parsed. Print warning message in case of
	register type mismatch between instruction operand and parsed
	register expression.
	* doc/as.texi: Document new s390-specific assembler options
	"[no-]warn-regtype-mismatch[=strict|relaxed|no]".
	* NEWS: Mention new s390-specific register name type checks and
	related assembler option "warn-regtype-mismatch=strict|
	relaxed|no".
	* testsuite/gas/s390/s390.exp: Add test cases for new assembler
	option "warn-regtype-mismatch={strict|relaxed}".
	* testsuite/gas/s390/esa-g5.s: Fix register types in tests for
	didbr, diebr, tbdr, and tbedr.
	* testsuite/gas/s390/zarch-z13.s: Fix register types in tests
	for vgef, vgeg, vscef, and vsceg.
	* testsuite/gas/s390/zarch-warn-regtype-mismatch-strict.s:
	Tests for assembler option "warn-regtype-mismatch=strict".
	* testsuite/gas/s390/zarch-warn-regtype-mismatch-strict.l:
	Likewise.
	* gas/testsuite/gas/s390/zarch-warn-regtype-mismatch-relaxed.s:
	Tests for assembler option "warn-regtype-mismatch=relaxed".
	* gas/testsuite/gas/s390/zarch-warn-regtype-mismatch-relaxed.l:
	Likewise.
	* gas/testsuite/gas/s390/zarch-omitted-base-index-err.s: Update
	test cases for assembler option "warn-regtype-mismatch"
	defaulting to "relaxed".
	* testsuite/gas/s390/zarch-omitted-base-index-err.l: Likewise.

include/
	* opcode/s390.h (S390_INSTR_FLAG_PSEUDO_MNEMONIC): Add
	instruction flag to tag .insn pseudo-mnemonics.

opcodes/
	* s390-opc.c (s390_opformats): Tag .insn pseudo-mnemonics as
	such.

Reviewed-by: Andreas Krebbel <krebbel@linux.ibm.com>
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2024-03-01 12:45:14 +01:00
Indu Bhagat
9dd9781ab0 gas: doc: update documentation for the new listing option
Add a new listing option, -i, to emit ginsn in the listing output.  We
may also emit other SCFI information if necessary in the future.

ginsn are most useful when seen alongside the assembly instructions.
Hence, they are emitted when the user includes the assembly instructions
in the listing output, i.e., "-ali=FILE".

gas/doc/:
	* as.texi: Add documentation for the new listing option, -i.
2024-01-15 03:31:35 -08:00
Indu Bhagat
ad9bd833d4 gas: add new command line option --scfi=experimental
When the command line option --scfi=experimenta is passed to the GNU
assembler, it will synthesize DWARF call frame information (CFI) for the
input assembly.

The option --scfi=experimental will also ignore most of the existing
.cfi_* directives, if already contained in the provided input file.
Only the following CFI directives will not be ignored:
  - .cfi_sections,
  - .cfi_label,
  - .cfi_signal_frame

To use SCFI, a target will need to:
    - define TARGET_USE_SCFI and TARGET_USE_GINSN, and other necessary
    definitions,
    - provide means to help GAS understand the target specific instruction
    semantics by creating ginsns.

The upcoming support for SCFI is inteded to be experimental, hence the
option --scfi=experimental.  The --scfi= may see more options like
--scfi=[all,none] added in future, once the SCFI support in GAS is
mature and robust.  The offering may also see for example, an
--scfi=inline option for dealing with inline asm may be added in the
future.  In --scfi=inline option, the GNU assembler may consume (and not
ignore) the compiler generated CFI for the code surrounding the inline
asm.

Also document the option.

gas/
        * as.c (show_usage): Add support for --scfi=experimental.
        (parse_args): Likewise.
        * as.h (enum synth_cfi_type): Define new type.
        * doc/as.texi: Document the new option.
2024-01-15 03:31:35 -08:00
Samuel Tardieu
53ba8c1117 gas/doc: fix several typos
Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
2024-01-08 13:53:49 +00:00
Jan Beulich
8fd892f4dd gas: correct .bss documentation for non-ELF
Only ELF permits the specification of a subsection, and even there not
consistently: csky, mcore, and spu handle .bss similar to .lcomm.
2024-01-05 08:13:09 +01:00
Alan Modra
fd67aa1129 Update year range in copyright notice of binutils files
Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.
2024-01-04 22:58:12 +10:30
Michael J. Eager
1a64c35996 Added support in gas for mlittle-endian and mbig-endian flags as options.
Updated show usage for MicroBlaze specific assembler options
to include new entries.

This patch has been tested for years of AMD Xilinx Yocto
releases as part of the following patch set:

https://github.com/Xilinx/meta-xilinx/tree/master/meta-microblaze/recipes-devtools/binutils/binutils

Signed-off-by: nagaraju <nagaraju.mekala@amd.com>
Signed-off-by: Neal Frager <neal.frager@amd.com>

---
V1->V2:
 - removed new options which were unnecessary
 - added documentation for MicroBlaze specific options

Signed-off-by: Michael J. Eager <eager@eagercon.com>
2023-09-28 13:14:37 -07:00
Jan Beulich
cefaa117f7 gas/ELF: allow "inheriting" section attributes and type
While --sectname-subst is nice, it isn't enough to e.g. mimic
-f{function,data}-sections in assembly code, when such use is to be
optional (e.g. dependent upon some configuration setting).

Assign meaning to '+' and '-' as section attribute letters, allowing
to inherit the prior section's attributes (and possibly type) along
with adding or removing some. Note that documenting the interaction
with '?' as undefined is a precautionary measure.

While touching the function invocation, stop using |= on the result of
obj_elf_parse_section_letters(): "attr" is firmly zero ahead of the
call.
2023-08-25 14:55:12 +02:00
Paul Iannetta
6e712424f5 kvx: New port. 2023-08-16 14:22:54 +01:00
David Carew
db583cf8dc as: Fix typo in manual
The -D flag should enable "debugging"
2023-08-05 03:43:39 +00:00
Maciej W. Rozycki
011365baca GAS/doc: Correct Tag_GNU_MIPS_ABI_MSA attribute description
Rewrite the paragraph to match the style of Tag_GNU_MIPS_ABI_FP text
immediately above, correcting grammar and formatting at the same time.

	gas/
	* doc/as.texi (MIPS Attributes): Correct Tag_GNU_MIPS_ABI_MSA
	attribute description.
2023-06-15 04:45:03 +01:00
Jan Beulich
762acf217c gas: maintain O_constant signedness in more cases
Unary '~' doesn't really produce an unsigned result. Neither does
subtraction (unless taking operand values into consideration). And an
abstract operator applied to two operands which aren't both unsigned
can't be assumed to yield an unsigned result; exceptions are
- shifts, where only signedness of the left hand operand matters,
- comparisons, which - unlike unary '!' - produce signed results (they
  deliver 0 or ~0, as opposed to '!', which yields 0 or 1),
- logical operators (yielding 0 or 1 and hence treated like unary '!').

While doing this (specifically while extending the all/quad testcase),
update .quad and .8byte documentation: With 64-bit architectures now
being common, it is highly inappropriate to state that these directives
unconditionally require bignums.
2023-05-19 09:16:04 +02:00
Alan Modra
4cb88cfae8 PR11601, Solaris assembler compatibility doesn't work
Well, it doesn't work on x86 or ppc, which both have # starting
comments anywhere on a line.  I think it is therefore only useful on
sparc.

	PR 11601
	* config/obj-elf.c (obj_elf_section_word): Only compile for sparc.
	(obj_elf_section): Only support solaris .section directive on
	sparc.
	* doc/as.texi (Section): Mention that solaris .section
	directive is only supported for sparc.
2023-05-18 09:33:14 +09:30
YunQiang Su
973f18b57c gas: documents .gnu_attribute Tag_GNU_MIPS_ABI_MSA
It is added since 2016 by
  Add support for .MIPS.abiflags and .gnu.attributes sections
  b52717c0e1
But never documented.
2023-05-06 16:41:26 +08:00
Nick Clifton
2dd1c6e88a Fix assembler documentation regarding data directives.
PR 30206
 * doc/as.texi (Pseudo Ops): Document that data directives such as .byte and .int are not intended for encoding instructions.
2023-03-14 11:19:45 +00:00
Alan Modra
d87bef3a7b Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
Indu Bhagat
b52c4ee466 gas: generate .sframe from CFI directives
Currently supported for x86_64 and aarch64 only.

[PS: Currently, the compiler has not been adapted to generate
".cfi_sections" with ".sframe" in it.  The newly added command line
option of --gsframe provides an easy way to try out .sframe support
in the toolchain.]

gas interprets the CFI directives to generate DWARF-based .eh_frame
info.  These internal DWARF structures are now consumed by
gen-sframe.[ch] sub-system to, in turn, create the SFrame unwind
information.  These internal DWARF structures are read-only for the
purpose of SFrame unwind info generation.

SFrame unwind info generation does not impact .eh_frame unwind info
generation.  Both .eh_frame and .sframe can co-exist in an ELF file,
if so desired by the user.

Recall that SFrame unwind information only contains the minimal
necessary information to generate backtraces and does not provide
information to recover all callee-saved registers.  The reason being
that callee-saved registers other than FP are not needed for stack
unwinding, and hence are not included in the .sframe section.

Consequently, gen-sframe.[ch] only needs to interpret a subset of
DWARF opcodes in gas.  More details follow.

[Set 1, Interpreted] The following opcodes are interpreted:
- DW_CFA_advance_loc
- DW_CFA_def_cfa
- DW_CFA_def_cfa_register
- DW_CFA_def_cfa_offset
- DW_CFA_offset
- DW_CFA_remember_state
- DW_CFA_restore_state
- DW_CFA_restore

[Set 2, Bypassed] The following opcodes are acknowledged but are not
necessary for generating SFrame unwind info:
- DW_CFA_undefined
- DW_CFA_same_value

Anything else apart from the two above-mentioned sets is skipped
altogether.  This means that any function containing a CFI directive not
in Set 1 or Set 2 above, will not have any SFrame unwind information
generated for them.  Holes in instructions covered by FREs of a single
FDE are not representable in the SFrame unwind format.

As few examples, following opcodes are not processed for .sframe
generation, and are skipped:
- .cfi_personality*
- .cfi_*lsda
- .cfi_escape
- .cfi_negate_ra_state
- ...

Not processing .cfi_escape, .cfi_negate_ra_state will cause SFrame
unwind information to be absent for SFrame FDEs that contain these CFI
directives, hence affecting the asynchronicity.

x86-64 and aarch64 backends need to have a few new definitions and
functions for .sframe generation.  These provide gas with architecture
specific information like the SP/FP/RA register numbers and an
SFrame-specific ABI marker.

Lastly, the patch also implements an optimization for size, where
specific fragments containing SFrame FRE start address and SFrame FDE
function are fixed up.  This is similar to other similar optimizations
in gas, where fragments are sized and fixed up when the associated
symbols can be resolved.  This optimization is controlled by a #define
SFRAME_FRE_TYPE_SELECTION_OPT and should be easy to turn off if needed.
The optimization is on by default for both x86_64 and aarch64.

ChangeLog:

	* gas/Makefile.am: Include gen-sframe.c and sframe-opt.c.
	* gas/Makefile.in: Regenerated.
	* gas/as.h (enum _relax_state): Add new state rs_sframe.
	(sframe_estimate_size_before_relax): New function.
	(sframe_relax_frag): Likewise.
	(sframe_convert_frag): Likewise.
	* gas/config/tc-aarch64.c (aarch64_support_sframe_p): New
	definition.
	(aarch64_sframe_ra_tracking_p): Likewise.
	(aarch64_sframe_cfa_ra_offset): Likewise.
	(aarch64_sframe_get_abi_arch): Likewise.
	(md_begin): Set values of sp/fp/ra registers.
	* gas/config/tc-aarch64.h (aarch64_support_sframe_p): New
	declaration.
	(support_sframe_p): Likewise.
	(SFRAME_CFA_SP_REG): Likewise.
	(SFRAME_CFA_FP_REG): Likewise.
	(SFRAME_CFA_RA_REG): Likewise.
	(aarch64_sframe_ra_tracking_p): Likewise.
	(sframe_ra_tracking_p): Likewise.
	(aarch64_sframe_cfa_ra_offset): Likewise.
	(sframe_cfa_ra_offset): Likewise.
	(aarch64_sframe_get_abi_arch): Likewise.
	(sframe_get_abi_arch): Likewise.
	* gas/config/tc-i386.c (x86_support_sframe_p): New definition.
	(x86_sframe_ra_tracking_p): Likewise.
	(x86_sframe_cfa_ra_offset): Likewise.
	(x86_sframe_get_abi_arch): Likewise.
	* gas/config/tc-i386.h (x86_support_sframe_p): New declaration.
	(support_sframe_p): Likewise.
	(SFRAME_CFA_SP_REG): Likewise.
	(SFRAME_CFA_FP_REG): Likewise.
	(x86_sframe_ra_tracking_p): Likewise.
	(sframe_ra_tracking_p): Likewise.
	(x86_sframe_cfa_ra_offset): Likewise.
	(sframe_cfa_ra_offset): Likewise.
	(x86_sframe_get_abi_arch): Likewise.
	(sframe_get_abi_arch): Likewise.
	* gas/config/tc-xtensa.c (unrelaxed_frag_max_size): Add case for
	rs_sframe.
	* gas/doc/as.texi: Add .sframe to the documentation for
	.cfi_sections.
	* gas/dw2gencfi.c (cfi_finish): Create a .sframe section.
	* gas/dw2gencfi.h (CFI_EMIT_sframe): New definition.
	* gas/write.c (cvt_frag_to_fill): Handle rs_sframe.
	(relax_segment): Likewise.
	* gas/gen-sframe.c: New file.
	* gas/gen-sframe.h: New file.
	* gas/sframe-opt.c: New file.
2022-11-15 15:24:06 -08:00
Indu Bhagat
b07a297816 gas: add new command line option --gsframe
When --gsframe is specified, the assembler will generate a .sframe
section from the CFI directives in the assembly.

ChangeLog:

	* gas/as.c (parse_args): Parse args and set flag_gen_sframe.
	* gas/as.h: Introduce skeleton for --gsframe.
	* gas/doc/as.texi: document --gsframe.
2022-11-15 15:23:57 -08:00
Nick Clifton
7ebd68d142 The help document of as misses some many options
PR 29623
	* as.c (show_usage): Document the --dump-config,
	--gdwarf-cie-version, --hash-size, --multibyte-handling,
	and --reduce-memory-overheads options.
	* config/tc-i386.c (md_show_usage): Document the -O option.
	* doc/as.texi: Document the --dump-config, --emulation,
	--hash-size, and --reduce-memory-overheads options.
2022-09-28 12:56:04 +01:00
Fangrui Song
2cac01e3ff binutils, gdb: support zstd compressed debug sections
PR29397 PR29563: Add new configure option --with-zstd which defaults to
auto.  If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support
zstd compressed debug sections for most tools.

* bfd: for addr2line, objdump --dwarf, gdb, etc
* gas: support --compress-debug-sections=zstd
* ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd
* objcopy: support ELFCOMPRESS_ZSTD input for
  --decompress-debug-sections and --compress-debug-sections=zstd
* gdb: support ELFCOMPRESS_ZSTD input.  The bfd change references zstd
  symbols, so gdb has to link against -lzstd in this patch.

If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error.  We
can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this
is too heavyweight, so don't do it for now.

```
% ld/ld-new a.o
ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...

% ld/ld-new a.o --compress-debug-sections=zstd
ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support

% binutils/objcopy --compress-debug-sections=zstd a.o b.o
binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support

% binutils/objcopy b.o --decompress-debug-sections
binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
...
```
2022-09-26 19:50:13 -07:00
Stepan Nemec
410a3464e7 Another gas manual typo correction. 2022-08-09 16:12:42 +01:00
Stepan Nemec
f561730710 Fix typos in assembler documentation. 2022-08-09 15:39:02 +01:00
Andreas Krebbel
69341966de IBM zSystems: Add support for z16 as CPU name.
So far z16 was identified as arch14. After the machine has been
announced we can now add the real name.

gas/ChangeLog:

	* config/tc-s390.c (s390_parse_cpu): Add z16 as alternate CPU
	name.
	* doc/as.texi: Add z16 and arch14 to CPU string list.
	* doc/c-s390.texi: Add z16 to CPU string list.

opcodes/ChangeLog:

	* s390-mkopc.c (main): Enable z16 as CPU string in the opcode
	table.
2022-04-07 07:54:29 +02:00
Jan Beulich
b3446f947b gas: retain whitespace between strings
Macro arguments may be separated by commas or just whitespace. Macro
arguments may also be quoted (where one level of quotes is removed in
the course of determining the values for the respective formal
parameters). Furthermore this quote removal knows _two_ somewhat odd
escaping mechanisms: One, apparently in existence forever, is that a
pair of quotes counts as the escaping of a quote, with the pair being
transformed to a single quote in the course of quote removal. The other
(introduced by c06ae4f232) looks more usual on the surface in that it
deals with \" sequences, but it _retains_ the escaping \. Hence only the
former mechanism is suitable when the value to be used by the macro body
is to contain a quote. Yet this results in ambiguity of what "a""b" is
intended to mean; elsewhere (e.g. for .ascii) it represents two
successive string literals. However, in any event is the above different
from "a" "b": I don't think this can be viewed the same as "a""b" when
processing macro arguments.

Change the scrubber to retain such whitespace, by making the processing
of strings more similar to that of symbols. And indeed this appears to
make sense when taking into account that for quite a while gas has been
supporting quoted symbol names.

Taking a more general view, however, the change doesn't go quite far
enough. There are further cases where significant whitespace is removed
by the scrubber. The new testcase enumerates a few in its ".if 0"
section. I'm afraid the only way that I see to deal with this would be
to significantly simplify the scrubber, such that it wouldn't do much
more than collapse sequences of unquoted whitespace into a single blank.
To be honest problems in this area aren't really surprising when seeing
that there's hardly any checking of .macro use throughout the testsuite
(and in particular in the [relatively] generic tests under all/).
2022-03-23 08:41:54 +01:00
Richard Sandiford
b4b0dcfd03 gas/doc: Fix "a true results" typo 2022-02-11 15:08:46 +00:00
Jan Beulich
d02f2788c3 gas/doc: mention quoted symbol names 2022-01-11 15:43:34 +01:00
Alan Modra
a2c5833233 Update year range in copyright notice of binutils files
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.

The copy of cgen was with commit d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
2022-01-02 12:04:28 +10:30
Nick Clifton
578c64a45a Add multibyte character warning option to the assembler.
* as.c (parse_args): Add support for --multibyte-handling.
	* as.h (multibyte_handling): Declare.
	* app.c (scan_for_multibyte_characters): New function.
	(do_scrub_chars): Call the new function if multibyte warning is
	enabled.
	* input-scrub,c (input_scrub_next_buffer): Call the multibyte
	scanning function if multibyte warnings are enabled.
	* symbols.c (struct symbol_flags): Add multibyte_warned bit.
	(symbol_init): Call the multibyte scanning function if multibyte
	symbol warnings are enabled.
	(S_SET_SEGMENT): Likewise.
	* NEWS: Mention the new feature.
	* doc/as.texi: Document the new feature.
	* testsuite/gas/all/multibyte.s: New test source file.
	* testsuite/gas/all/multibyte1.d: New test driver file.
	* testsuite/gas/all/multibyte1.l: New test expected output.
	* testsuite/gas/all/multibyte2.d: New test driver file.
	* testsuite/gas/all/multibyte2.l: New test expected output.
	* testsuite/gas/all/gas.exp: Run the new tests.
2021-11-18 16:48:19 +00:00
Eric Botcazou
f9402ccaa9 Deal with full path in .file 0 directive
Gas uses the directory part, if present, of the .file 0 directive to set
entry 0 of the directory table in DWARF 5, which represents the "current
directory".

Now Gas also uses the file part of the same directive to set entry 0 of the
file table, which represents the "current compilation file".  But the latter
need not be located in the former so GCC will use a full path in the file
part when it is passed a full path:

gcc -c /full/path/test.c -save-temps

yields:

 .file 0 "/current/directory" "/full/path/test.c"

in the assembly file and:

 The Directory Table (offset 0x22, lines 2, columns 1):
  Entry Name
  0     (indirect line string, offset: 0x25): /current/directory
  1     (indirect line string, offset: 0x38): /full/path

 The File Name Table (offset 0x30, lines 2, columns 2):
  Entry Dir     Name
  0     0       (indirect line string, offset: 0x43): /full/path/test.c

in the object file.  Note the full path and the questionable Dir value in
the 0 entry of the file table.
2021-11-15 12:56:10 +01:00
liuzhensong
4462d7c440 LoongArch gas support
2021-10-22  Chenghua Xu  <xuchenghua@loongson.cn>
            Zhensong Liu  <liuzhensong@loongson.cn>
            Weinan Liu  <liuweinan@loongson.cn>
	    Xiaolin Tang  <tangxiaolin@loongson.cn>

gas/
	* Makefile.am: Add LoongArch.
	* NEWS: Mention LoongArch support.
	* config/loongarch-lex-wrapper.c: New.
	* config/loongarch-lex.h: New.
	* config/loongarch-lex.l: New.
	* config/loongarch-parse.y: New.
	* config/tc-loongarch.c: New.
	* config/tc-loongarch.h: New.
	* configure.ac: Add LoongArch.
	* configure.tgt: Likewise.
	* doc/as.texi: Likewise.
	* doc/c-loongarch.texi: Likewise.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* po/POTFILES.in: Regenerate.
gas/testsuite/
	* gas/all/gas.exp: Add LoongArch.
	* gas/elf/elf.exp: Likewise.
	* gas/loongarch/4opt_op.d: New.
	* gas/loongarch/4opt_op.s: Likewise.
	* gas/loongarch/fix_op.d: Likewise.
	* gas/loongarch/fix_op.s: Likewise.
	* gas/loongarch/float_op.d: Likewise.
	* gas/loongarch/float_op.s: Likewise.
	* gas/loongarch/imm_op.d: Likewise.
	* gas/loongarch/imm_op.s: Likewise.
	* gas/loongarch/jmp_op.d: Likewise.
	* gas/loongarch/jmp_op.s: Likewise.
	* gas/loongarch/load_store_op.d: Likewise.
	* gas/loongarch/load_store_op.s: Likewise.
	* gas/loongarch/loongarch.exp: Likewise.
	* gas/loongarch/macro_op.d: Likewise.
	* gas/loongarch/macro_op.s: Likewise.
	* gas/loongarch/nop.d: Likewise.
	* gas/loongarch/nop.s: Likewise.
	* gas/loongarch/privilege_op.d: Likewise.
	* gas/loongarch/privilege_op.s: Likewise.
	* gas/loongarch/syscall.d: Likewise.
	* gas/loongarch/syscall.s: Likewise.
	* lib/gas-defs.exp: Add LoongArch.
2021-10-24 21:36:32 +10:30
Jan Beulich
e74e2b4c33 x86/ELF: fix .ds.x output
The ELF psABI-s are quite clear here: On 32-bit the underlying data type
is 12 bytes long (with 2 bytes of trailing padding), while on 64-bit it
is 16 bytes long (with 6 bytes of padding). Make s_space() capable of
handling 'x' (and 'p') type floating point being other than 12 bytes
wide (also adjusting documentation). This requires duplicating the
definition of X_PRECISION in the target speciifc header; the compiler
would complain if this was out of sync with config/atof-ieee.c.

Note that for now padding space doesn't get separated from actual
storage, which means that things will work correctly only for little-
endian cases, and which also means that by specifying large enough
numbers padding space can be set to non-zero. Since the logic is needed
for a single little-endian architecture only for now, I'm hoping that
this might be acceptable for the time being; otherwise the change will
become more intrusive.

Note also that this brings the emitted data size of .ds.x vs .tfloat in
line for non-ELF targets as well; the issue will be even more obvious
when further taking into account a subsequent patch fixing .dc.x/.dcb.x
(where output sizes currently differ depending on input format).

Extend existing x86 testcases.
2021-08-11 08:31:03 +02:00
Nick Clifton
476654beae Add a generic .bss directive for ELF based targets.
PR 3136
	* config/obj-elf.c (elf_pseudo_table): Add entry for .bss.
	(obj_elf_bss): New function.  Change to the .bss section.
	Support an optional subsection number.
	(obj_elf_change_section): Call obj_elf_section_change_hook.
	(obj_elf_section): Likewise.
	(obj_elf_data): Likewise.
	(obj_elf_text): Likewise.
	(obj_elf_struct): Likewise.
	(obj_elf_subsection): Likewise.
	(obj_elf_previous): Likewise.
	* config/obj-elf.h (obj_elf_bss): Prototype.
	* doc/as.texi (Bss): New node.
2021-05-07 17:08:48 +01:00
Mike Frysinger
5fda40b28f gas: make [248]byte directives available everywhere
These aren't specific to ELF at all, and seem generally useful.
So pull them out of the ELF backend and into the common core.
2021-01-14 20:43:40 -05:00
Marcus Comstedt
286d2f2cd7 RISC-V: Mention -mbig-endian and -mlittle-endian in doc
gas/
    * doc/as.texi: Add -mlittle-endian and -mbig-endian to docs.
    * doc/c-riscv.texi: Likewise.
2021-01-06 18:08:20 +08:00
Alan Modra
250d07de5c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
Alan Modra
058430b4a1 Re: Stop Gas from generating line info or address ranges
* doc/as.texi (.nop): Document optional size arg.
	* dwarf2dbg.c (dwarf2_gen_line_info_1): Only check SEC_ALLOC
	when ELF.  Warn whenever dwarf line number information is ignored.
	* frags.c (frag_offset_ignore_align_p): New function.
	* frags.h (frag_offset_ignore_align_p): Declare.
	* read.c (s_nop): Extend to support optional size arg.
	* testsuite/gas/elf/dwarf2-20.d: Expect warnings, and exact range.
	* testsuite/gas/elf/dwarf2-20.s: Emit 16 bytes worth of nops.
	* testsuite/gas/m68hc11/indexed12.d: Expect warnings.
2020-11-18 23:46:39 +10:30
Jozef Lawrynowicz
99fabbc973 Support SHF_GNU_RETAIN ELF section flag
The SHF_GNU_RETAIN section flag is an extension to the GNU ELF OSABI.
It is defined as follows:

=========================================================
Section Attribute Flags
+-------------------------------------+
| Name           | Value              |
+-------------------------------------+
| SHF_GNU_RETAIN | 0x200000 (1 << 21) |
+-------------------------------------+

SHF_GNU_RETAIN
  The link editor should not garbage collect the section.
=========================================================

The .section directive accepts the "R" flag, which indicates
SHF_GNU_RETAIN should be applied to the section.

There is not a direct mapping of SHF_GNU_RETAIN to the BFD
section flag SEC_KEEP. Keeping these flags distinct allows
SHF_GNU_RETAIN sections to be explicitly removed by placing them in
/DISCARD/.

bfd/ChangeLog:

	* elf-bfd.h (enum elf_gnu_osabi): Add elf_gnu_osabi_retain.
	(struct elf_obj_tdata): Increase has_gnu_osabi to 4 bits.
	* elf.c (_bfd_elf_make_section_from_shdr): Set elf_gnu_osabi_retain
	for SHF_GNU_RETAIN.
	(_bfd_elf_final_write_processing): Report if SHF_GNU_RETAIN is
	not supported by the OSABI.
	Adjust error messages.
	* elflink.c (elf_link_input_bfd): Copy enabled has_gnu_osabi bits from
	input BFD to output BFD.
	(bfd_elf_gc_sections): gc_mark the section if SHF_GNU_RETAIN is set.

binutils/ChangeLog:

	* NEWS: Announce SHF_GNU_RETAIN support.
	* readelf.c (get_elf_section_flags): Handle SHF_GNU_RETAIN.
	Recognize SHF_GNU_RETAIN and SHF_GNU_MBIND only for supported OSABIs.
	* testsuite/binutils-all/readelf.exp: Run new tests.
	Don't run run_dump_test when there isn't an assembler available.
	* testsuite/lib/binutils-common.exp (supports_gnu_osabi): Adjust
	comment.
	* testsuite/binutils-all/readelf-maskos-1a.d: New test.
	* testsuite/binutils-all/readelf-maskos-1b.d: New test.
	* testsuite/binutils-all/readelf-maskos.s: New test.
	* testsuite/binutils-all/retain1.s: New test.
	* testsuite/binutils-all/retain1a.d: New test.
	* testsuite/binutils-all/retain1b.d: New test.

gas/ChangeLog:

	* NEWS: Announce SHF_GNU_RETAIN support.
	* config/obj-elf.c (obj_elf_change_section): Merge SHF_GNU_RETAIN bit
	between section declarations.
	(obj_elf_parse_section_letters): Handle 'R' flag.
	Handle numeric flag values within the SHF_MASKOS range.
	(obj_elf_section): Validate SHF_GNU_RETAIN usage.
	* doc/as.texi: Document 'R' flag to .section directive.
	* testsuite/gas/elf/elf.exp: Run new tests.
	* testsuite/gas/elf/section10.d: Unset SHF_GNU_RETAIN bit.
	* testsuite/gas/elf/section10.s: Likewise.
	* testsuite/gas/elf/section22.d: New test.
	* testsuite/gas/elf/section22.s: New test.
	* testsuite/gas/elf/section23.s: New test.
	* testsuite/gas/elf/section23a.d: New test.
	* testsuite/gas/elf/section23b.d: New test.
	* testsuite/gas/elf/section23b.err: New test.
	* testsuite/gas/elf/section24.l: New test.
	* testsuite/gas/elf/section24.s: New test.
	* testsuite/gas/elf/section24a.d: New test.
	* testsuite/gas/elf/section24b.d: New test.

include/ChangeLog:

	* elf/common.h (SHF_GNU_RETAIN): Define.

ld/ChangeLog:

	* NEWS: Announce support for SHF_GNU_RETAIN.
	* ld.texi (garbage collection): Document SHF_GNU_RETAIN.
	(Output Section Discarding): Likewise.
	* testsuite/ld-elf/elf.exp: Run new tests.
	* testsuite/ld-elf/retain1.s: New test.
	* testsuite/ld-elf/retain1a.d: New test.
	* testsuite/ld-elf/retain1b.d: New test.
	* testsuite/ld-elf/retain2.d: New test.
	* testsuite/ld-elf/retain2.ld: New test.
	* testsuite/ld-elf/retain2.map: New test.
	* testsuite/ld-elf/retain3.d: New test.
	* testsuite/ld-elf/retain3.s: New test.
	* testsuite/ld-elf/retain4.d: New test.
	* testsuite/ld-elf/retain4.s: New test.
	* testsuite/ld-elf/retain5.d: New test.
	* testsuite/ld-elf/retain5.map: New test.
	* testsuite/ld-elf/retain5lib.s: New test.
	* testsuite/ld-elf/retain5main.s: New test.
	* testsuite/ld-elf/retain6a.d: New test.
	* testsuite/ld-elf/retain6b.d: New test.
	* testsuite/ld-elf/retain6lib.s: New test.
	* testsuite/ld-elf/retain6main.s: New test.
2020-11-18 11:51:13 +00:00