Skip to content

Commit

Permalink
Add predefined version identifiers for ELFv1 and ELFv2.
Browse files Browse the repository at this point in the history
For PPC64 LittleEndian a new ELF version was defined. While the common usage is
ELFv1 with big endian and ELFv2 with little endian, the other uses are also possible.
In fact gcc defines a command line switch --with-abi=elfv1 / --with-abi=elfv2 to choose
the ELF ABI.
The new predefined version identifiers ELFv1 / ELFv2 reflect the fact that this
information cannot be determined elsewhere.
See http://llvm.org/devmtg/2014-04/PDFs/Talks/Euro-LLVM-2014-Weigand.pdf for more
information on ELFv2.
  • Loading branch information
redstar committed Oct 27, 2014
1 parent 11276b8 commit 2c47bae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cond.c
Expand Up @@ -213,6 +213,8 @@ bool VersionCondition::isPredefined(const char *ident)
"Alpha_HardFloat",
"LittleEndian",
"BigEndian",
"ELFv1",
"ELFv2",
"D_Coverage",
"D_Ddoc",
"D_InlineAsm_X86",
Expand Down
5 changes: 5 additions & 0 deletions src/mars.c
Expand Up @@ -444,25 +444,30 @@ int tryMain(size_t argc, const char *argv[])
#elif TARGET_LINUX
VersionCondition::addPredefinedGlobalIdent("Posix");
VersionCondition::addPredefinedGlobalIdent("linux");
VersionCondition::addPredefinedGlobalIdent("ELFv1");
global.params.isLinux = true;
#elif TARGET_OSX
VersionCondition::addPredefinedGlobalIdent("Posix");
VersionCondition::addPredefinedGlobalIdent("OSX");
VersionCondition::addPredefinedGlobalIdent("ELFv1");
global.params.isOSX = true;

// For legacy compatibility
VersionCondition::addPredefinedGlobalIdent("darwin");
#elif TARGET_FREEBSD
VersionCondition::addPredefinedGlobalIdent("Posix");
VersionCondition::addPredefinedGlobalIdent("FreeBSD");
VersionCondition::addPredefinedGlobalIdent("ELFv1");
global.params.isFreeBSD = true;
#elif TARGET_OPENBSD
VersionCondition::addPredefinedGlobalIdent("Posix");
VersionCondition::addPredefinedGlobalIdent("OpenBSD");
VersionCondition::addPredefinedGlobalIdent("ELFv1");
global.params.isFreeBSD = true;
#elif TARGET_SOLARIS
VersionCondition::addPredefinedGlobalIdent("Posix");
VersionCondition::addPredefinedGlobalIdent("Solaris");
VersionCondition::addPredefinedGlobalIdent("ELFv1");
global.params.isSolaris = true;
#else
#error "fix this"
Expand Down

0 comments on commit 2c47bae

Please sign in to comment.