fix(ldgen): don't emit intermediate placements without sections

When a symbol needs to be placed to a different target than the one
designated for the object file, the object file is expanded, which
includes the following steps:

1. Creating a new placement for the symbol's input section with the
   specified target.
2. Excluding the object placement from the orignal target.
3. Creating a new intermediate placement for the object for the original
   target, where its input sections are expanded, excluding the input
   section for the symbol.

Let's illustrate the object expansion process with the following example:

[sections:rodata]
entries:
    .rodata+
    .sdata2+
    .srodata+

[scheme:default]
entries:
    text -> flash_text
    rodata -> flash_rodata

[scheme:noflash]
entries:
    text -> iram0_text
    rodata -> dram0_data

[mapping:soc_pm]
archive: libsoc.a
entries:
    gpio_periph: GPIO_HOLD_MASK (noflash)

gpio_periph section headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        00000000 000034 000000 00  AX  0   0  2
  [ 2] .data             PROGBITS        00000000 000034 000000 00  WA  0   0  1
  [ 3] .bss              NOBITS          00000000 000034 000000 00  WA  0   0  1
  [ 4] .rodata.GPIO_HOLD_MASK PROGBITS        00000000 000034 000058 00   A  0   0  4
  [ 5] .rodata.GPIO_PIN_MUX_REG PROGBITS        00000000 00008c 000058 00   A  0   0  4
  [ 6] .debug_info       PROGBITS        00000000 0000e4 0000d8 00      0   0  1
  [ 7] .rela.debug_info  RELA            00000000 0009d4 000108 0c   I 16   6  4
  [ 8] .debug_abbrev     PROGBITS        00000000 0001bc 000070 00      0   0  1
  [ 9] .debug_aranges    PROGBITS        00000000 00022c 000018 00      0   0  1
  [10] .rela.debug_aranges RELA            00000000 000adc 00000c 0c   I 16   9  4
  [11] .debug_line       PROGBITS        00000000 000244 0001ab 00      0   0  1
  [12] .debug_str        PROGBITS        00000000 0003ef 00022d 01  MS  0   0  1
  [13] .comment          PROGBITS        00000000 00061c 000030 01  MS  0   0  1
  [14] .note.GNU-stack   PROGBITS        00000000 00064c 000000 00      0   0  1
  [15] .riscv.attributes RISCV_ATTRIBUTES 00000000 00064c 000044 00      0   0  1
  [16] .symtab           SYMTAB          00000000 000690 000260 10     17  36  4
  [17] .strtab           STRTAB          00000000 0008f0 0000e1 00      0   0  1
  [18] .shstrtab         STRTAB          00000000 000ae8 0000d1 00      0   0  1

1. Creating a new placement
.dram0.data :
{
    *libsoc.a:gpio_periph.*(.rodata.GPIO_HOLD_MASK .sdata2.GPIO_HOLD_MASK .srodata.GPIO_HOLD_MASK)
}

2. Excluding the object placement
.flash.rodata :
{
    *(EXCLUDE_FILE(*libsoc.a:gpio_periph.*) .rodata.* ...)
}

3. Creating a new intermediate placement
.flash.rodata :
{
    *libsoc.a:gpio_periph.*(.rodata.GPIO_PIN_MUX_REG)
}

Now, let's do the same, but also move GPIO_PIN_MUX_REG to noflash with an updated mapping.

[mapping:soc_pm]
archive: libsoc.a
entries:
    gpio_periph: GPIO_HOLD_MASK (noflash)
    gpio_periph: GPIO_PIN_MUX_REG (noflash)

1. Creating a new placement
.dram0.data :
{
    *libsoc.a:gpio_periph.*(.rodata.GPIO_HOLD_MASK .sdata2.GPIO_HOLD_MASK .srodata.GPIO_HOLD_MASK)
    *libsoc.a:gpio_periph.*(.rodata.GPIO_PIN_MUX_REG .sdata2.GPIO_PIN_MUX_REG
                            .srodata.GPIO_PIN_MUX_REG)
}

2. Excluding the object placement
.flash.rodata :
{
    *(EXCLUDE_FILE(*libsoc.a:gpio_periph.*) .rodata.* ...)
}

3. Creating a new intermediate placement
.flash.rodata :
{
    *libsoc.a:gpio_periph.*
}

The *libsoc.a:gpio_periph.* entity in step 3 no longer has input
sections, as there are no remaining .rodata input sections in the object
file. The linker behavior for this mapping is to include all object
input sections that have not yet been placed as described in
https://sourceware.org/binutils/docs/ld.html#Input-Section-Basics
"If you use a file name without a list of sections, then all sections in
the input file will be included in the output section. This is not
commonly done, but it may by useful on occasion."

The map file for such mapping now contains following input sections

 .flash.rodata   0x3c0a0120    0x19b34
     *libsoc.a:gpio_periph.*()
     .debug_info    0x3c0b95bf       0xd8 esp-idf/soc/libsoc.a(gpio_periph.c.obj)
     .debug_abbrev  0x3c0b9697       0x70 esp-idf/soc/libsoc.a(gpio_periph.c.obj)
     .debug_aranges
                    0x3c0b9707       0x18 esp-idf/soc/libsoc.a(gpio_periph.c.obj)
     .debug_line    0x3c0b971f      0x1ab esp-idf/soc/libsoc.a(gpio_periph.c.obj)
     .debug_str     0x3c0b98ca      0x21a esp-idf/soc/libsoc.a(gpio_periph.c.obj)
                                    0x22d (size before relaxing)
     .comment       0x3c0b9ae4       0x30 esp-idf/soc/libsoc.a(gpio_periph.c.obj)
     .note.GNU-stack
                    0x3c0b9ae4        0x0 esp-idf/soc/libsoc.a(gpio_periph.c.obj)
     .riscv.attributes
                    0x3c0b9ae4       0x44 esp-idf/soc/libsoc.a(gpio_periph.c.obj)

This is incorrect, and such intermediate placement should not be
generated. This type of placement can be recognized because it is not
explicitly defined in the mapping and lacks input sections. We can
identify this in the significant function and prevent issuing commands
for such placement.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata 2025-01-15 18:46:24 +01:00
parent 15da152e21
commit c06b3d213e
3 changed files with 635 additions and 8 deletions

View File

@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import collections
@ -83,11 +83,22 @@ class Placement:
#
# Placement can also be a basis if it has flags
# (self.flags) or its basis has flags (self.basis.flags)
return (not self.basis or
self.target != self.basis.target or
(self.flags and not self.basis.flags) or
(not self.flags and self.basis.flags) or
self.force)
significant = (not self.basis or
self.target != self.basis.target or
(self.flags and not self.basis.flags) or
(not self.flags and self.basis.flags) or
self.force)
if significant and not self.explicit and not self.sections:
# The placement is significant, but it is an intermediate placement
# for an expanded object with no input sections. In this situation,
# report the placement as not significant, so its command is not
# emitted in the linker script. Otherwise, only the entity without
# input sections would be emitted, and the linker would include
# all input sections that have not yet been mapped.
significant = False
return significant
def force_significant(self):
if not self.is_significant():

View File

@ -0,0 +1,570 @@
In archive build/esp-idf/soc/libsoc.a:
lldesc.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .text.lldesc_setup_link_constrained 0000010c 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
4 .text.lldesc_get_received_len 00000026 00000000 00000000 00000140 2**1
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
5 .debug_info 00000299 00000000 00000000 00000166 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
6 .debug_abbrev 0000019d 00000000 00000000 000003ff 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
7 .debug_loc 0000016c 00000000 00000000 0000059c 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
8 .debug_aranges 00000028 00000000 00000000 00000708 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
9 .debug_ranges 00000030 00000000 00000000 00000730 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
10 .debug_line 000003fb 00000000 00000000 00000760 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
11 .debug_str 000002c8 00000000 00000000 00000b5b 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
12 .comment 00000030 00000000 00000000 00000e23 2**0
CONTENTS, READONLY
13 .note.GNU-stack 00000000 00000000 00000000 00000e53 2**0
CONTENTS, READONLY
14 .debug_frame 00000030 00000000 00000000 00000e54 2**2
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
15 .riscv.attributes 00000044 00000000 00000000 00000e84 2**0
CONTENTS, READONLY
dport_access_common.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .text.esp_dport_access_read_buffer 0000001a 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
4 .debug_info 000000f1 00000000 00000000 0000004e 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 00000089 00000000 00000000 0000013f 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_loc 0000001f 00000000 00000000 000001c8 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_aranges 00000020 00000000 00000000 000001e7 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
8 .debug_ranges 00000010 00000000 00000000 00000207 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
9 .debug_line 000001eb 00000000 00000000 00000217 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
10 .debug_str 00000245 00000000 00000000 00000402 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
11 .comment 00000030 00000000 00000000 00000647 2**0
CONTENTS, READONLY
12 .note.GNU-stack 00000000 00000000 00000000 00000677 2**0
CONTENTS, READONLY
13 .debug_frame 00000020 00000000 00000000 00000678 2**2
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
14 .riscv.attributes 00000044 00000000 00000000 00000698 2**0
CONTENTS, READONLY
interrupts.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.str1.4 000002e4 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rodata.esp_isr_names 000000f8 00000000 00000000 00000318 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
5 .debug_info 00000245 00000000 00000000 00000410 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
6 .debug_abbrev 00000086 00000000 00000000 00000655 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
7 .debug_aranges 00000018 00000000 00000000 000006db 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
8 .debug_line 000000ae 00000000 00000000 000006f3 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .debug_str 000008a5 00000000 00000000 000007a1 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
10 .comment 00000030 00000000 00000000 00001046 2**0
CONTENTS, READONLY
11 .note.GNU-stack 00000000 00000000 00000000 00001076 2**0
CONTENTS, READONLY
12 .riscv.attributes 00000044 00000000 00000000 00001076 2**0
CONTENTS, READONLY
gpio_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.GPIO_HOLD_MASK 00000058 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rodata.GPIO_PIN_MUX_REG 00000058 00000000 00000000 0000008c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .debug_info 000000d8 00000000 00000000 000000e4 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
6 .debug_abbrev 00000070 00000000 00000000 000001bc 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
7 .debug_aranges 00000018 00000000 00000000 0000022c 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
8 .debug_line 000001ab 00000000 00000000 00000244 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .debug_str 0000022d 00000000 00000000 000003ef 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
10 .comment 00000030 00000000 00000000 0000061c 2**0
CONTENTS, READONLY
11 .note.GNU-stack 00000000 00000000 00000000 0000064c 2**0
CONTENTS, READONLY
12 .riscv.attributes 00000044 00000000 00000000 0000064c 2**0
CONTENTS, READONLY
uart_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.uart_periph_signal 00000028 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 0000032e 00000000 00000000 0000005c 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000d4 00000000 00000000 0000038a 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 0000045e 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000001f9 00000000 00000000 00000476 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 0000093e 00000000 00000000 0000066f 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00000fad 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00000fdd 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00000fdd 2**0
CONTENTS, READONLY
adc_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.adc_channel_io_map 00000028 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 000000ac 00000000 00000000 0000005c 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 00000061 00000000 00000000 00000108 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 00000169 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000000a6 00000000 00000000 00000181 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 0000020b 00000000 00000000 00000227 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00000432 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00000462 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00000462 2**0
CONTENTS, READONLY
dedic_gpio_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.dedic_gpio_periph_signals 00000044 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 000002aa 00000000 00000000 00000078 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000bd 00000000 00000000 00000322 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 000003df 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 00000102 00000000 00000000 000003f7 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 0000090a 00000000 00000000 000004f9 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00000e03 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00000e33 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00000e33 2**0
CONTENTS, READONLY
gdma_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.gdma_periph_signals 0000001c 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 00000389 00000000 00000000 00000050 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000ac 00000000 00000000 000003d9 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 00000485 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 00000107 00000000 00000000 0000049d 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 00000b57 00000000 00000000 000005a4 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 000010fb 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 0000112b 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 0000112b 2**0
CONTENTS, READONLY
spi_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.spi_periph_signal 00000048 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
4 .debug_info 0000179e 00000000 00000000 0000007c 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000001bd 00000000 00000000 0000181a 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 000019d7 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 00000246 00000000 00000000 000019ef 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 0000121f 00000000 00000000 00001c35 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00002e54 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00002e84 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00002e84 2**0
CONTENTS, READONLY
ledc_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .srodata.ledc_periph_signal 00000001 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 000000e6 00000000 00000000 00000035 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 00000090 00000000 00000000 0000011b 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 000001ab 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000001ab 00000000 00000000 000001c3 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 0000023e 00000000 00000000 0000036e 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 000005ac 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 000005dc 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 000005dc 2**0
CONTENTS, READONLY
rmt_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.rmt_periph_signals 00000024 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 000002cc 00000000 00000000 00000058 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000d8 00000000 00000000 00000324 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 000003fc 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000000f4 00000000 00000000 00000414 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 000008e6 00000000 00000000 00000508 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00000dee 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00000e1e 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00000e1e 2**0
CONTENTS, READONLY
sdm_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.sigma_delta_periph_signals 00000010 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 0000009a 00000000 00000000 00000044 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 00000090 00000000 00000000 000000de 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 0000016e 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000000a6 00000000 00000000 00000186 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 000001b5 00000000 00000000 0000022c 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 000003e1 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00000411 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00000411 2**0
CONTENTS, READONLY
i2s_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.i2s_periph_signal 0000000e 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 0000037d 00000000 00000000 00000042 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000e7 00000000 00000000 000003bf 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 000004a6 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000001f7 00000000 00000000 000004be 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 00000988 00000000 00000000 000006b5 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 0000103d 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 0000106d 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 0000106d 2**0
CONTENTS, READONLY
i2c_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .srodata.i2c_periph_signal 00000006 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 000002c2 00000000 00000000 0000003a 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000bd 00000000 00000000 000002fc 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 000003b9 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000001f7 00000000 00000000 000003d1 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 00000912 00000000 00000000 000005c8 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00000eda 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00000f0a 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00000f0a 2**0
CONTENTS, READONLY
temperature_sensor_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.temperature_sensor_attributes 00000064 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 000000fd 00000000 00000000 00000098 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 00000090 00000000 00000000 00000195 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 00000225 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 000000c4 00000000 00000000 0000023d 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 00000271 00000000 00000000 00000301 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00000572 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 000005a2 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 000005a2 2**0
CONTENTS, READONLY
timer_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.timer_group_periph_signals 00000010 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 00000371 00000000 00000000 00000044 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000ac 00000000 00000000 000003b5 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 00000461 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 00000109 00000000 00000000 00000479 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 00000b65 00000000 00000000 00000582 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 000010e7 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00001117 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00001117 2**0
CONTENTS, READONLY
mpi_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.MPI_OPERATIONS_REG 0000000c 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .rodata.MPI_BLOCK_BASES 00000010 00000000 00000000 00000040 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .debug_info 000000ed 00000000 00000000 00000050 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
6 .debug_abbrev 00000070 00000000 00000000 0000013d 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
7 .debug_aranges 00000018 00000000 00000000 000001ad 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
8 .debug_line 000001a9 00000000 00000000 000001c5 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .debug_str 0000022f 00000000 00000000 0000036e 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
10 .comment 00000030 00000000 00000000 0000059d 2**0
CONTENTS, READONLY
11 .note.GNU-stack 00000000 00000000 00000000 000005cd 2**0
CONTENTS, READONLY
12 .riscv.attributes 00000044 00000000 00000000 000005cd 2**0
CONTENTS, READONLY
twai_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .rodata.twai_controller_periph_signals 0000001c 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .debug_info 00000396 00000000 00000000 00000050 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
5 .debug_abbrev 000000ac 00000000 00000000 000003e6 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
6 .debug_aranges 00000018 00000000 00000000 00000492 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
7 .debug_line 00000107 00000000 00000000 000004aa 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .debug_str 00000b92 00000000 00000000 000005b1 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
9 .comment 00000030 00000000 00000000 00001143 2**0
CONTENTS, READONLY
10 .note.GNU-stack 00000000 00000000 00000000 00001173 2**0
CONTENTS, READONLY
11 .riscv.attributes 00000044 00000000 00000000 00001173 2**0
CONTENTS, READONLY
wdt_periph.c.obj: file format elf32-littleriscv
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000034 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000034 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000034 2**0
ALLOC
3 .debug_info 00000072 00000000 00000000 00000034 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
4 .debug_abbrev 00000026 00000000 00000000 000000a6 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
5 .debug_aranges 00000018 00000000 00000000 000000cc 2**0
CONTENTS, RELOC, READONLY, DEBUGGING, OCTETS
6 .debug_line 00000060 00000000 00000000 000000e4 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
7 .debug_str 000001f8 00000000 00000000 00000144 2**0
CONTENTS, READONLY, DEBUGGING, OCTETS
8 .comment 00000030 00000000 00000000 0000033c 2**0
CONTENTS, READONLY
9 .note.GNU-stack 00000000 00000000 00000000 0000036c 2**0
CONTENTS, READONLY
10 .riscv.attributes 00000044 00000000 00000000 0000036c 2**0
CONTENTS, READONLY

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
#
import collections
@ -32,6 +32,7 @@ ROOT = Entity('*')
FREERTOS = Entity('libfreertos.a')
CROUTINE = Entity('libfreertos.a', 'croutine')
TIMERS = Entity('libfreertos.a', 'timers')
TEMPERATURE_SENSOR_PERIPH = Entity('libsoc.a', 'temperature_sensor_periph')
FREERTOS2 = Entity('libfreertos2.a')
@ -68,6 +69,9 @@ class GenerationTest(unittest.TestCase):
with open('data/libfreertos.a.txt') as objdump:
self.entities.add_sections_info(objdump)
with open('data/libsoc.a.txt') as objdump:
self.entities.add_sections_info(objdump)
with open('data/linker_script.ld') as linker_script:
self.linker_script_expect = LinkerScript(linker_script)
@ -336,6 +340,48 @@ entries:
self.compare_rules(expected, actual)
def test_nondefault_mapping_all_symbols(self):
# Test mapping entry different from default for all .rodata.* symbols in the temperature_sensor_periph
# object file. There should be exclusion in the default commands for flash_rodata, but
# no implicit intermediate object command(X), because there are no .rodata+
# symbols left to be placed in dram0_data.
#
# The X line with entity only(without any input sections) should not be emitted, because
# linker would include all not yet placed input sections from the temperature_sensor_periph
# object file, including .debug, .comment and other input section.
#
# flash.rodata
# *((EXCLUDE_FILE(*libsoc.a:temperature_sensor_periph.*)) .rodata.* ...) A
# # *libsoc.a:temperature_sensor_periph.* X
#
# Commands placing the entire library in iram should be generated:
#
# dram0_data
# *libsoc.a:temperature_sensor_periph.*(.rodata.temperature_sensor_attribute) B
mapping = u"""
[mapping:test]
archive: libsoc.a
entries:
temperature_sensor_periph:temperature_sensor_attributes (noflash) # 1
"""
self.add_fragments(mapping)
actual = self.generation.generate(self.entities, False)
expected = self.generate_default_rules()
flash_rodata = expected['flash_rodata']
dram0_data = expected['dram0_data']
# Generate exclusion in flash_text A
flash_rodata[0].exclusions.add(TEMPERATURE_SENSOR_PERIPH)
# Input section commands in dram0_data for #1 B
dram0_data.append(InputSectionDesc(TEMPERATURE_SENSOR_PERIPH,
set(['.rodata.temperature_sensor_attributes']),
[]))
self.compare_rules(expected, actual)
def test_default_symbol_nondefault_lib(self):
# Test default symbol mapping with different lib mapping. This should create an implicit intermediate object command.
# The significant targets are flash_text, flash_rodata, iram0_text, dram0_data.
@ -571,7 +617,7 @@ entries:
def test_multiple_symbols_excluded_from_intermediate_command(self):
# Test mapping multiple symbols from the same object.
# All these symbols must be succesfully excluded from
# All these symbols must be successfully excluded from
# the intermediate command.
#
# flash_text