Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

probe-run cannot load ELF linked with '-Tdefmt.x -Tlink.x' #143

@japaric

Description

@japaric

app-template passes the flags '-Tlink.x -Tdefmt.x' to the linker. ELFs linked with those flags work fine.
if you modify app-template and pass the flags in the reverse order '-Tdefmt.x -Tlink.x' the output ELF doesn't work with probe-run.

You get this kind of output:

$ probe-run --chip nrf52840 bad-elf
  (HOST) INFO  flashing program (0.00 KiB)
Error: No loadable ELF sections were found.

The .text section is marked as allocatable in the ELF though:

$ readelf -S bad-elf
Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .defmt            PROGBITS        00000000 000054 000002 00      0   0  1
  [ 2] .debug_abbrev     PROGBITS        00000000 000056 004589 00      0   0  1
  [ 3] .debug_info       PROGBITS        00000000 0045df 03280b 00      0   0  1
  [ 4] .debug_aranges    PROGBITS        00000000 036df0 003378 00      0   0  8
  [ 5] .debug_ranges     PROGBITS        00000000 03a168 018420 00      0   0  1
  [ 6] .debug_str        PROGBITS        00000000 052588 039ad8 01  MS  0   0  1
  [ 7] .debug_pubnames   PROGBITS        00000000 08c060 00cb53 00      0   0  1
  [ 8] .debug_pubtypes   PROGBITS        00000000 098bb3 005f71 00      0   0  1
  [ 9] .ARM.attributes   ARM_ATTRIBUTES  00000000 09eb24 00003a 00      0   0  1
  [10] .debug_frame      PROGBITS        00000000 09eb60 008bc4 00      0   0  4
  [11] .debug_line       PROGBITS        00000000 0a7724 02ef8a 00      0   0  1
  [12] .debug_loc        PROGBITS        00000000 0d66ae 0002a9 00      0   0  1
  [13] .comment          PROGBITS        00000000 0d6957 00006d 01  MS  0   0  1
  [14] .symtab           SYMTAB          00000000 0d69c4 002ab0 10     16 456  4
  [15] .shstrtab         STRTAB          00000000 0d9474 0000f0 00      0   0  1
  [16] .strtab           STRTAB          00000000 0d9564 0048bd 00      0   0  1
  [17] .vector_table     PROGBITS        00000000 0dde24 000100 00   A  0   0  4
  [18] .text             PROGBITS        00000100 0ddf24 003de4 00  AX  0   0  4
  [19] .rodata           PROGBITS        00003ee4 0e1d10 000c34 00  AM  0   0 16
  [20] .data             PROGBITS        20000000 0e2944 000030 00  WA  0   0  4
  [21] .bss              NOBITS          20000030 0e2974 000008 00  WA  0   0  4
  [22] .uninit           NOBITS          20000038 0e2974 000400 00  WA  0   0  4

OpenOCD is able to flash this ELF file.

It was observed that if you link the ELF with '-Tlink.x -Tdefmt.x' the .text and other sections appear first in the above list of section headers (and have small offsets).

It seems that the object library is unable to find the .text section in the ELF.
probe-run uses the object library to report the size of loadable sections (the "0.00 KiB" part in the above output)
probe-rs also uses the object library to locate loadable sections that need to be flashed on the device.

Metadata

Metadata

Labels

difficulty: mediumSomewhat difficult to solvepriority: mediumMedium priority for the Knurling teamstatus: needs designThis feature needs design work to move forwardtype: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions