Page 1 of 1

trouble embedding a string into .xe file

Posted: Fri Jul 25, 2014 7:24 am
by LyleHaze
I need to embed a version string into the .xe file for my project.
The string is generated automatically with version and date information and it follows the format

"\0$VER: programname version.revision (dd.mm.yyyy) comment\0"

It can be located anywhere in the file, it is located later by the header \0$VER:
I have tried various combinations of static, const, and used without any luck.
Surely there is a simple way to embed this string into the .xecutable file.

Thanks!
LyleHaze

Re: trouble embedding a string into .xe file

Posted: Mon Aug 11, 2014 10:26 am
by richard
The tools normally eliminate unreferenced code / data at link time to reduce the size of the binary, which is probably why the variables you declared didn't appear in the binary. I'd suggest creating an assembly file (e.g. version.S) with the following contents:

Code: Select all

.section .version, "", @progbits
.ascii "\0$VER: programname version.revision (dd.mm.yyyy) comment\0"
This section won't be eliminated by the tools since the data has not be placed in an elimination block using the .cc_top / .cc_bottom directives. The section won't be loaded into memory since the allocatable ('a') flag is not set so it won't consume any memory at runtime (i.e. it will only exist in the .xe file).

Re: trouble embedding a string into .xe file

Posted: Wed Aug 13, 2014 9:54 pm
by LyleHaze
Marvelous!
Wonderful!
Various other expletives designating positive thoughts!

Works nicely.

Since most of our projects will have "matching" programs in the computer and the XMOS chip, it is my goal to get them to use the same version headers, so that they will match as the program develops.

I tried something like this:

Code: Select all

// project_rev.h
#define VERSION		53
#define REVISION	2
#define DATE		"13.8.2014"
#define VERS		"X-Logger 53.2"
#define VSTRING		"X-Logger 53.2 (13.8.2014)\r\n"
#define VERSTAG		"\0$VER: X-Logger 53.2 (13.8.2014)"

Code: Select all

#include "project_rev.h"
.section .version, "", @progbits
.ascii VERSTAG
without luck.. it complained of extra characters after the .ascii directive.

So I wrote a simple C program to read our format and write yours.
Working great.

Thanks very much for your help!