Page MenuHomePhabricator

[lld][ELF] Support BFD name elf32-avr
ClosedPublic

Authored by benshi001 on Fri, May 13, 6:43 AM.

Diff Detail

Event Timeline

benshi001 created this revision.Fri, May 13, 6:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, May 13, 6:43 AM
benshi001 requested review of this revision.Fri, May 13, 6:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptFri, May 13, 6:43 AM
benshi001 added inline comments.Fri, May 13, 6:44 AM
lld/test/ELF/linkerscript/avr5.test
16

This two disassembled lines corresponds to

	sts   abc+1, r25
	sts   abc, r24

in the original assmebly source.

We can see that the address of variable abc is 100, which is correct.

benshi001 added inline comments.Fri, May 13, 6:46 AM
lld/test/ELF/linkerscript/avr5.test
12

I expect to check both section addresses and variable addresses.

benshi001 added inline comments.Fri, May 13, 6:47 AM
lld/test/ELF/linkerscript/avr5.test
25

AVR is harward CPU, it is common that program memory and data memory are isolated to two different regions.

MaskRay added inline comments.Fri, May 13, 11:13 PM
lld/ELF/ScriptParser.cpp
440

move this after EM_386

lld/test/ELF/linkerscript/Inputs/avr5.s
5 ↗(On Diff #429226)

These instructions are not meaningful to ld. One single rjmp _start is sufficient testing a relocation.

lld/test/ELF/linkerscript/avr5.test
3

Use split-file

25

Is it common to start at zero address?

benshi001 updated this revision to Diff 429449.Sat, May 14, 7:20 AM
benshi001 marked an inline comment as done.
benshi001 marked 2 inline comments as done.Sat, May 14, 7:27 AM
benshi001 added inline comments.
lld/test/ELF/linkerscript/Inputs/avr5.s
5 ↗(On Diff #429226)

Unfortunately rjmp can not be decoded correctly by llvm-objdump, due to bugs in AVR Disassembler (But GNU's avr-bjdump can). Currently I have to use LDI, which load an int8 immediate to a register.

lld/test/ELF/linkerscript/avr5.test
25

Yes. Most devices reset to PC = 0.

benshi001 marked an inline comment as done.Sat, May 14, 7:28 AM
benshi001 marked an inline comment as done.
benshi001 added inline comments.
lld/test/ELF/linkerscript/avr5.test
3

Done. Splited to two .test files.

benshi001 marked an inline comment as done.Sat, May 14, 7:30 AM
benshi001 added inline comments.Sat, May 14, 7:34 AM
lld/test/ELF/linkerscript/avr5-relocs.test
8 ↗(On Diff #429449)

VMA of variable def is 0x802, so 2 => r24 and 8 => r25.

benshi001 updated this revision to Diff 429461.Sat, May 14, 8:22 AM
MaskRay added inline comments.Sat, May 14, 5:12 PM
lld/test/ELF/linkerscript/avr5-relocs.test
11 ↗(On Diff #429461)
lld/test/ELF/linkerscript/avr5-sections.test
1 ↗(On Diff #429461)

The tests should be merged into one.

Add a file-level comment explaining the purpose.

Use split-file to avoid Inputs/* files.

benshi001 updated this revision to Diff 429499.Sat, May 14, 5:51 PM
benshi001 marked an inline comment as done.Sat, May 14, 6:03 PM
benshi001 added inline comments.
lld/test/ELF/linkerscript/avr5-sections.test
1 ↗(On Diff #429461)

I am not familiar with that.

do you mean:

  1. make a unique .s file with assembly
  2. echo to a temp linker script
  3. do all checks ?
MaskRay added inline comments.Sat, May 14, 6:05 PM
lld/test/ELF/linkerscript/avr5-sections.test
1 ↗(On Diff #429461)

rg split-file in this directory and see I use split-file.

benshi001 updated this revision to Diff 429501.Sat, May 14, 6:50 PM
benshi001 marked 2 inline comments as done.
benshi001 added inline comments.
lld/test/ELF/linkerscript/avr5-sections.test
1 ↗(On Diff #429461)

A file level comment is added.

1 ↗(On Diff #429461)

I have combined all files into avr5.test with split-file.

benshi001 marked an inline comment as done.Sat, May 14, 6:52 PM
benshi001 updated this revision to Diff 429502.Sat, May 14, 7:10 PM
benshi001 added inline comments.
lld/test/ELF/linkerscript/avr5-relocs.test
11 ↗(On Diff #429461)

I have added a check line for that OUTPUT_ARCH(avr:5) input:

# HEAD: 0x5, EF_AVR_ARCH_AVR5
MaskRay accepted this revision.Tue, May 17, 11:13 AM
MaskRay added inline comments.
lld/test/ELF/linkerscript/avr5.test
4
This revision is now accepted and ready to land.Tue, May 17, 11:13 AM
MaskRay retitled this revision from [lld][ELF] Support linking 'elf32-avr' with linker scripts to [lld][ELF] Support elf32-avr BFD name.Tue, May 17, 11:14 AM
MaskRay retitled this revision from [lld][ELF] Support elf32-avr BFD name to [lld][ELF] Support BFD name elf32-avr.
This revision was automatically updated to reflect the committed changes.