U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rasmus Villemoes <ravi@prevas.dk>
To: Simon Glass <sjg@chromium.org>
Cc: <u-boot@lists.denx.de>,  Tom Rini <trini@konsulko.com>
Subject: Re: [RFC PATCH 8/9] linker_lists.h: emit lots of meta-data for debugging and sanity checking
Date: Wed, 27 May 2026 00:41:13 +0200	[thread overview]
Message-ID: <87qzmxequu.fsf@prevas.dk> (raw)
In-Reply-To: <87v7c9erip.fsf@prevas.dk> (Rasmus Villemoes's message of "Wed, 27 May 2026 00:26:54 +0200")

On Wed, May 27 2026, Rasmus Villemoes <ravi@prevas.dk> wrote:

> On Mon, May 25 2026, Simon Glass <sjg@chromium.org> wrote:
>
>
>>> diff --git a/include/linker_lists.h b/include/linker_lists.h
>>> @@ -23,7 +24,45 @@
>>> +#define ll_emit_type_info(_list, _type) \
>>> +     __asm__(                                                \
>>> +             ".pushsection "ll_info_section_name(_list)',\'aw\'\n'   \
>>> +             ".type "ll_size_symbol_name(_list)", STT_OBJECT\n"      \
>>> +             ".size "ll_size_symbol_name(_list)", %c0\n"             \
>>> +             ".type "ll_align_symbol_name(_list)", STT_OBJECT\n"     \
>>> +             ".size "ll_align_symbol_name(_list)", %c1\n"            \
>>> +             ll_size_symbol_name(_list)':\n'                         \
>>> +             ll_align_symbol_name(_list)':\n'                        \
>>> +             '.popsection\n'                                         \
>>> +             : : 'i'(sizeof(_type)), 'i'(__alignof__(_type)))
>>
>> This is extended asm (it has operand constraints), so GCC requires it
>> to be inside a function.
>
> Not exactly. My 'info gcc' has this to say:
>
>   Similarly to basic ‘asm’, extended ‘asm’ statements may be used both
>   inside a C function or at file scope ("top-level"), where you can use
>   this technique to emit assembler directives, define assembly language
>   macros that can be invoked elsewhere in the file, or write entire
>   functions in assembly language.  Extended ‘asm’ statements outside of
>   functions may not use any qualifiers, may not specify clobbers, may
>   not use ‘%’, ‘+’ or ‘&’ modifiers in constraints and can only use
>   constraints which don't allow using any register.
>
> and since the only constraints I use are those that provide an immediate
> to the asm, that should be ok (and WorksForMe).

Ah, that's actually new in gcc 15 (I'm using gcc
16). https://gcc.gnu.org/gcc-15/changes.html says

  Extended inline assembler statements can now be used with some
  limitations outside of functions as well.

and explicitly calls out

  "i" (sizeof (struct S))); /* It is possible to pass constants to toplevel asm.  */

>> ll_start_decl()/ll_end_decl() pull this into
>> ll_emit_start_symbol/ll_emit_end_symbol at file scope - see
>> SUITE_DECL() in test/cmd_ut.c
>>
>> One way out is to drop the operands and have the C side emit a
>> zero-initialised marker object whose array dimensions encode
>> sizeof/__alignof__ - e.g. a static struct in a dedicated section whose
>> two members are sized sizeof(_type) and __alignof__(_type). That costs
>> a few bytes per list per TU but keeps the trick working at file scope.

Yes, but this is the kind of growth that I wanted to avoid. And if I put
those marker objects in a section of their own, I'll have to modify each
and every linker script to preserve that to the u-boot binary, but
ensure that the objcopy step throws it away.

I'll think about this some more.

Rasmus

  reply	other threads:[~2026-05-26 22:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 21:27 [RFC PATCH 0/9] linker list sanity checking Rasmus Villemoes
2026-05-22 21:27 ` [RFC PATCH 1/9] sandbox: Drop special link order treatment of start.o and sdl.o Rasmus Villemoes
2026-05-25 14:30   ` Simon Glass
2026-05-22 21:27 ` [RFC PATCH 2/9] linker_lists: Do not set "unused" attribute Rasmus Villemoes
2026-05-25 15:02   ` Simon Glass
2026-05-25 15:22     ` Tom Rini
2026-05-25 15:33       ` Simon Glass
2026-05-25 15:46         ` Tom Rini
2026-06-12 18:25           ` Simon Glass
2026-05-22 21:27 ` [RFC PATCH 3/9] event: Remove obsolete comment and __used attributes Rasmus Villemoes
2026-05-25 14:31   ` Simon Glass
2026-05-22 21:27 ` [RFC PATCH 4/9] linker_lists.h: add ll_*_name() helper macros Rasmus Villemoes
2026-05-22 22:44   ` Tom Rini
2026-05-25 14:32   ` Simon Glass
2026-05-22 21:27 ` [RFC PATCH 5/9] linker_lists.h: drop _2 from section and symbol name prefix Rasmus Villemoes
2026-05-22 22:44   ` Tom Rini
2026-05-25 15:02   ` Simon Glass
2026-05-26 21:44     ` Rasmus Villemoes
2026-05-27  4:41       ` Simon Glass
2026-05-22 21:27 ` [RFC PATCH 6/9] linker_lists.rst: update documentation Rasmus Villemoes
2026-05-22 22:45   ` Tom Rini
2026-05-25 15:03   ` Simon Glass
2026-05-26 21:49     ` Rasmus Villemoes
2026-05-22 21:27 ` [RFC PATCH 7/9] test: avoid use of special characters in ELF section names Rasmus Villemoes
2026-05-22 22:45   ` Tom Rini
2026-05-25 15:03   ` Simon Glass
2026-05-22 21:27 ` [RFC PATCH 8/9] linker_lists.h: emit lots of meta-data for debugging and sanity checking Rasmus Villemoes
2026-05-25 14:28   ` Simon Glass
2026-05-26 22:26     ` Rasmus Villemoes
2026-05-26 22:41       ` Rasmus Villemoes [this message]
2026-05-27  4:09         ` Simon Glass
2026-05-22 21:27 ` [RFC PATCH 9/9] tools: add linker-lists.py parser/checker script Rasmus Villemoes
2026-05-25 15:04   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87qzmxequu.fsf@prevas.dk \
    --to=ravi@prevas.dk \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox