gcc arm inline asm: how to output value for .set directive?

Liste des GroupesRevenir à ca embedded 
Sujet : gcc arm inline asm: how to output value for .set directive?
De : invalid (at) *nospam* invalid.invalid (Grant Edwards)
Groupes : comp.arch.embedded
Date : 03. Apr 2025, 23:04:38
Autres entêtes
Organisation : PANIX Public Access Internet and UNIX, NYC
Message-ID : <vsn0lm$2k4$1@reader1.panix.com>
User-Agent : slrn/1.0.3 (Linux)
How do I convince ARM GCC's extended asm() to emit a value that can be
used in a .set directive?  Here's a simplified example:

    #include <stdint.h>
   
    typedef struct
    {
      uint8_t  what[32];
      uint32_t ever[2];
      unsigned foo;
      uint8_t bar[20];
    } shm_t;
   
    void foo(void)
    {
      asm("\t.global foo_offset");
      asm("\t.set foo_offset, 40");
      asm("\t.set foo_offset, %[off]" : : [off] "i" ( __builtin_offsetof(shm_t, foo) ) : );
    }

The first of the two .set directive works.  The second one doesn't.
The offsetof() value is being used as desired, but gcc is prefixing
the value with a '#' (presumably it thinks it's an instruction operand
and not a directive operand). Here's an excerpt from the assembly
listing:

  28              @ 13 "foo.c" 1
  29              .global foo_offset
  30              @ 0 "" 2
  31              @ 14 "foo.c" 1
  32              .set foo_offset, 40
  33              @ 0 "" 2
  34              @ 15 "foo.c" 1
  35              .set foo_offset, #40
  36              @ 0 "" 2

And of course the assembler chucks a wobbly at line 35:

/tmp/cc1TaWVh.s: Assembler messages:
/tmp/cc1TaWVh.s:35: Error: bad expression
/tmp/cc1TaWVh.s:35: Error: junk at end of line, first unrecognized character is `4'

I've tried a bunch of gcc extended assembly input value constraints
and modifiers, but can't find the magic code that emits the value "40"
without the '#' on the front.

Any ideas?




Date Sujet#  Auteur
3 Apr 25 * gcc arm inline asm: how to output value for .set directive?3Grant Edwards
4 Apr 25 `* Re: gcc arm inline asm: how to output value for .set directive?2Grant Edwards
4 Apr 25  `- Re: gcc arm inline asm: how to output value for .set directive?1David Brown

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal