diff options
author | Nick Clifton <nickc@redhat.com> | 2023-02-16 16:27:08 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2023-02-16 16:27:08 +0000 |
commit | 9fe129a4105bb59398f73ce96938a94f19265b79 (patch) | |
tree | 33772b47038b290b37158f78813bab4ce8360958 /ld/ld.texi | |
parent | 6f63b61dd116becf96f47bb2dec61edd59f88a08 (diff) | |
download | gdb-9fe129a4105bb59398f73ce96938a94f19265b79.zip gdb-9fe129a4105bb59398f73ce96938a94f19265b79.tar.gz gdb-9fe129a4105bb59398f73ce96938a94f19265b79.tar.bz2 |
Add support for the ASCII directive inside linker scripts.
* ldlex.l: Add ASCII token.
* ldgram.y: Add parsing of the ASCII command.
* ldlang.c (lang_add_string): Add maximum size parameter. Move escape character handling code into separate function.
* ldlang.h (lang_add_string): Update prototype.
* NEWS: Mention the new feature.
* ld.texi (Output Section Data): Document the new directives.
* testsuite/ld-scripts/asciz.t: Adjust to work on more architectures and to test more aspects of the ASCIZ directive.
* testsuite/ld-scripts/asciz.d: Adjust to match the changes to the test linker script.
* testsuite/ld-scripts/ascii.d: New test driver.
* testsuite/ld-scripts/ascii.s: New test assembler source.
* testsuite/ld-scripts/ascii.t: New test script.
* testsuite/ld-scripts/script.exp: Run the new test.
Diffstat (limited to 'ld/ld.texi')
-rw-r--r-- | ld/ld.texi | 53 |
1 files changed, 40 insertions, 13 deletions
@@ -5308,7 +5308,6 @@ C identifiers because they contain a @samp{.} character. @cindex data @cindex section data @cindex output section data -@kindex ASCIZ ``@var{string}'' @kindex BYTE(@var{expression}) @kindex SHORT(@var{expression}) @kindex LONG(@var{expression}) @@ -5345,18 +5344,6 @@ When the object file format does not have an explicit endianness, as is true of, for example, S-records, the value will be stored in the endianness of the first input object file. -You can include a zero-terminated string in an output section by using -@code{ASCIZ}. The keyword is followed by a string which is stored at -the current value of the location counter adding a zero byte at the -end. If the string includes spaces it must be enclosed in double -quotes. The string may contain '\n', '\r', '\t' and octal numbers. -Hex numbers are not supported. - -For example, this string of 16 characters will create a 17 byte area -@smallexample - ASCIZ "This is 16 bytes" -@end smallexample - Note---these commands only work inside a section description and not between them, so the following will produce an error from the linker: @smallexample @@ -5367,6 +5354,46 @@ whereas this will work: SECTIONS @{@ .text : @{@ *(.text) ; LONG(1) @}@ .data : @{@ *(.data) @}@ @}@ @end smallexample +@cindex output section strings +@kindex ASCII (@var{expression}) ``@var{string}'' +@kindex ASCIZ ``@var{string}'' +You can include a zero-terminated string in an output section by using +@code{ASCIZ}. The keyword is followed by a string which is stored at +the current value of the location counter including adding a zero byte +at the end. Any length of string is supported by this directive. + +You can include a fixed size string in an output section by using +@code{ASCII}. The keyword is followed by a size enclosed in +parentheses and then a string. The string is stored at the current +value of the location counter and zero bytes are added at the end to +fill up to the specified size. Note the fill value is ignored for +this padding. + +If the string is too long, a warning is issued and the string is +truncated. The string will still be zero-terminated in this case. + +If the expression evaluates to zero then the directive will be treated +as if it were @code{ASCIZ} instead. + +If the string in an @code{ASCII} or @code{ASCIZ} command includes spaces +it must be enclosed in double quotes. + +The string can have C escape characters like '\n', '\r', '\t' and +octal numbers. The '\"' escape is not supported. Nor are escaped hex +values. + +Example 1: This is string of 16 characters and will create a 32 byte +area: +@smallexample + ASCII (32) "This is 16 bytes" +@end smallexample + +Example 2: This is a string of 16 characters and will create a 17 byte +area: +@smallexample + ASCIZ "This is 16 bytes" +@end smallexample + @kindex FILL(@var{expression}) @cindex holes, filling @cindex unspecified memory |