simulavr-devel
[Top][All Lists]
Advanced

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

[Simulavr-devel] Implementing device signatures


From: Petr Hluzín
Subject: [Simulavr-devel] Implementing device signatures
Date: Sun, 22 Jan 2012 19:43:00 +0100

Hi folks

User may include `#include <avr/signature.h>' in source code, this
will create a new ELF section. We can use that to detect which device
was user's program compiled for when the ELF file is loaded via --file
on command line or `load' via GDB [1], or by a script.

The implementation will touch many files, mostly in a minor way.
However people may get upset on the style I chose. Therefore I ask:
how should I implement that?

User visible stuff:
A: If user does not enter `--device=XYZ' and we support the ELF
signature, create the device
B: If user does enter `--device=XYZ' and and the ELF signature
matches, continue normally
C: If user does enter `--device=XYZ' and and the ELF signature does
not match and we do not support the signature, continue normally
D: If user does enter `--device=XYZ' and and the ELF signature does
not match and we do support the signature, then report error
E: If the ELF image does not contain a signature, then trust user or fail.

The case C is needed to workaround limited set of devices supported by
simulavr. Other cases are pretty clear.
The implementation has to allow querying when no device is created (is
signature known, create from signature, ...) and when a device is
created (does that have this signature).

Possibilities:
AvrFactory: add a map<signature,name> or map
<signature,AvrDeviceCreator>, or some other map.
AVR_REGISTER: add a macro parameter or pass "well-know" name of
signature (member constant, #define)
AvrDevice: add a virtual function or a member variable
each device: implement AvrDevice's virtual function or set AvrDevice's
member variable

There are several ways to do that, neither looks significantly better
to me. Someone may have an opinion, therefore I ask you.

[1] 
http://git.savannah.gnu.org/cgit/simulavr.git/commit/?id=4e38167e0464c360df9971192a6d4e4e01dc3998

-- 
Petr Hluzin



reply via email to

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