ASCIZ Command for output section

Adds a new directive to the linker script syntax: ASCIZ.
This inserts a zero-terminated string into the output at the place where it is used.
This commit is contained in:
Ulf Samuelsson
2023-02-14 10:13:28 +00:00
committed by Nick Clifton
parent 12ef683055
commit 0d79a2a8e2
10 changed files with 157 additions and 3 deletions

View File

@@ -0,0 +1,17 @@
#source: asciz.s
#ld: -T asciz.t
#objdump: -s -j .text
#target: [is_elf_format]
#skip: mips*-*-*
#skip: tilegx*-*-* tilepro-*-*
# COFF, PE and MIPS targets align code to a 16 byte boundary
# tilegx andtilepro aligns code to a 8 byte boundary.
.*: file format .*
Contents of section .text:
.... 01010101 54686973 20697320 61207374 ....This is a st
.... 72696e67 00...... ........ ........ ring............
.... 54686973 20697320 616e6f74 68657220 This is another
.... 0a737472 696e6753 00 .stringS........
#pass

View File

@@ -0,0 +1,8 @@
.section .text
.long 0x01010101
.section .data
.long 0x9abcdef0
.section .bss
.long 0

View File

@@ -0,0 +1,23 @@
MEMORY {
rom : ORIGIN = 0x00000, LENGTH = 0x10000
ram : ORIGIN = 0x10000, LENGTH = 0x10000
}
_start = 0x000000;
SECTIONS
{
. = 0x1000 + SIZEOF_HEADERS;
.text ALIGN (0x20) :
{
*(.text)
ASCIZ "This is a string"
. = ALIGN(0x20);
align_label = .;
ASCIZ "This is another \nstring\123"
unalign_label = .;
}
.data : AT (0x10000) { *(.data) } >ram /* NO default AT>rom */
. = ALIGN(0x20);
.bss : { *(.bss) } >ram /* NO default AT>rom */
/DISCARD/ : { *(*) }
}

View File

@@ -227,6 +227,7 @@ foreach test_script $test_script_list {
run_dump_test [string range $test_script 0 end-2]
}
run_dump_test "asciz"
run_dump_test "align-with-input"
run_dump_test "pr20302"
run_dump_test "output-section-types"