public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105863] New: RFE: __attribute__((incbin("file"))) or __builtin_incbin("file")
@ 2022-06-06 16:52 hpa at zytor dot com
  2022-06-06 17:36 ` [Bug c/105863] " pinskia at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: hpa at zytor dot com @ 2022-06-06 16:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105863

            Bug ID: 105863
           Summary: RFE: __attribute__((incbin("file"))) or
                    __builtin_incbin("file")
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hpa at zytor dot com
  Target Milestone: ---

It is a *very* common operation to want to include a preexisting binary object
into a compiled project. There are a number of ways to do this, but they all
suffer significant shortcomings.

The most common ways are to use a preprocessor to convert the input binary
object to textual source, or to wrap an object in assembly code and use
.incbin.  The former is *extremely* inefficient, the latter has a number of
pitfalls, including the one described in bug 66871, the need for
platform-specific coding, sizeof() not being functional, etc.

I would like to suggest a variable attribute __attribute__((incbin("file")))
which statically initializes a variable to the contents of the given binary
file, or a __builtin_incbin("file") which would expand to an initializer; the
end result would look either like:

char foobar[] __attribute__((incbin("foobar.bin")));
char foobar[] = __builtin_incbin("foobar.bin");

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-06-14 19:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06 16:52 [Bug c/105863] New: RFE: __attribute__((incbin("file"))) or __builtin_incbin("file") hpa at zytor dot com
2022-06-06 17:36 ` [Bug c/105863] " pinskia at gcc dot gnu.org
2022-06-06 17:43 ` amonakov at gcc dot gnu.org
2022-06-13 12:59 ` rguenth at gcc dot gnu.org
2023-06-05 19:55 ` [Bug c/105863] RFE: C23 #embed hpa at zytor dot com
2023-06-22 15:16 ` mpolacek at gcc dot gnu.org
2023-06-22 20:42 ` joseph at codesourcery dot com
2024-05-15 15:33 ` jakub at gcc dot gnu.org
2024-05-15 16:16 ` hpa at zytor dot com
2024-05-16 20:41 ` jsm28 at gcc dot gnu.org
2024-05-17 12:08 ` jakub at gcc dot gnu.org
2024-05-20 20:35 ` jsm28 at gcc dot gnu.org
2024-06-11 15:01 ` jakub at gcc dot gnu.org
2024-06-13 14:45 ` jakub at gcc dot gnu.org
2024-06-14  8:19 ` jakub at gcc dot gnu.org
2024-06-14 19:35 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).