avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] What (Binary) Tags?


From: Dean
Subject: [avr-libc-dev] What (Binary) Tags?
Date: Tue, 18 Dec 2007 18:58:34 +1100

Hi guys,

Was just wondering about the possibility of providing a standardised way to 
embedd data into the resulting compiled binary, for purely identification 
purposes. There already exists the "what" standard, where tags are prefixed by 
the string @(#) to indicate a purely identificational tag.

Such tags can already be created manually with the PROGMEM tag, but this 
suffers from the problem that the data isn't actually referenced anywhere in 
the program (it is designed to be read out by a host, etc. for IDing the source 
version/etc. of a binary) and so is removed if -ffunction-sections and 
--gc-sections is applied. This can be subverted with the application of the 
used and externally_visible attributes.

I propose a new macro, either:

=================================================================
#define PROGMEM_TAG PROGMEM __attribute__((used, externally_visible))
=================================================================

Example use:

=================================================================
const char PROGMEM_TAG VersionTag = "@(#)1.2.3";
=================================================================



Or the what-tag standardised version:

=================================================================
#define BINARY_TAG(id, data) const struct BinaryTagData BINTAG_##id             
\
                                  PROGMEM  __attribute__((used, 
externally_visible)) = \
                                  {MagicString: BINARY_TAG_HEADER, TagData: 
data}

#define BINARY_TAG_HEADER          {'@','(','#',')'}

struct BinTagData
{
    char MagicString[4];
    char TagData[];
};
=================================================================

Example use:

=================================================================
BINARY_TAG(VersionTag, "1.2.3");
=================================================================


The latter route is already used with my "ButtTags" for my ButtLoad project, 
and works quite well.

- Dean


reply via email to

[Prev in Thread] Current Thread [Next in Thread]