avr: inline assembly with lo8()/hi8() cuts symbols longer than 16 characters

Ouverte
#205 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
c

Piste de recherche

The issue provides a minimal C example using inline assembly and reproduces the symbol truncation with AVR target flags; start by reading that example and tracing how EmbCC parses or emits inline assembly containing lo8() or hi8(). Check the AVR port context in arch/avr/avr_context.c for the affected long symbols. Done means the example compiles with those symbols intact and the AVR RTOS library can build.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug

On AVR, an inline-assembly template that uses lo8() or hi8() anywhere has every symbol longer than 16 characters cut to its first 16, and the assembler then refuses it. EmbCC 0.1.0 (macOS aarch64 release), --target=avr -mmcu=atmega328p -Os.

void abcdefghijklmnopqrst(void);
void g(void) { __asm__ __volatile__("ldi r18, lo8(2303)\n\tcall abcdefghijklmnopqrst" ::: "r18"); }
embcc: g.c:2: error: 'abcdefghijklmnop' is not a number, a register or an expression this assembler knows

What changes the result:

Template Result
ldi r18, lo8(2303) then call abcdefghijklmnopqrst error
ldi r18, hi8(2303) then call … error
call … first, then ldi r18, lo8(2303) error
ldi r18, lo8(2303), nop, then jmp … error
ldi r18, 7 then call abcdefghijklmnopqrst compiles
call abcdefghijklmnopqrst alone, with or without operands compiles
a 16-character name after lo8() compiles

So the cut follows the presence of lo8/hi8 in the block, not their position or the operands.

Where EmbLinkRTOS meets it: the AVR port's kernel start, arch/avr/avr_context.c, loads the stack pointer with lo8(%[top])/hi8(%[top]) and then calls emb_arch_switch_to and jumps to embk_thread_launch, both 18 characters. The port's library does not compile, so no Uno image links. Passing the two bytes as separate "i" operands avoids it; the RTOS keeps lo8/hi8, which avr-gcc and Clang accept.

Part of #184 (AVR).

Langage dominant
C
Étoiles
1
Forks
2
Merge moyen
20 h 55 min
PR mergées (30 j)
73

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de EmbLinkOs/EmbCC

Toutes les issues de EmbLinkOs/EmbCC

Issues similaires

Plus d'issues C

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.