[llvm-commits] [PATCH] Native Client: Set correct ELF metadata
David Meyer
pdox at google.com
Fri Sep 9 08:11:40 PDT 2011
Bill,
Premature generalization? New patch attached.
- pdox
On Fri, Sep 9, 2011 at 2:39 AM, Bill Wendling <wendling at apple.com> wrote:
> On Sep 9, 2011, at 1:05 AM, David Meyer wrote:
>
>> This patch teaches MC/ELFObjectWriter to set the correct ABI version,
>> OS ABI, and EFlags for emitting Native Client ELF objects.
>>
> These switches seem a bit heavy-handed. Why not just if-then-else statements?
>
> + // e_ident[EI_ABIVERSION]
> + switch (TargetObjectWriter->getOSType()) {
> + case Triple::NativeClient: Write8(ELF::ELFABIVERSION_NACL); break;
> + default: Write8(0); break;
> + }
> +
> WriteZeros(ELF::EI_NIDENT - ELF::EI_PAD);
>
> Write16(ELF::ET_REL); // e_type
> @@ -1283,7 +1289,12 @@
>
> // FIXME: get the real EABI Version from the Triple.
> void ARMELFObjectWriter::WriteEFlags() {
> - Write32(ELF::EF_ARM_EABIMASK & DefaultEABIVersion);
> + unsigned EFlags = ELF::EF_ARM_EABIMASK & DefaultEABIVersion;
> + switch (TargetObjectWriter->getOSType()) {
> + case Triple::NativeClient: EFlags |= ELF::EF_NACL_ALIGN_16; break;
> + default: break;
> + }
> + Write32(EFlags);
> }
>
> // In ARM, _MergedGlobals and other most symbols get emitted directly.
> @@ -1642,6 +1653,15 @@
> X86ELFObjectWriter::~X86ELFObjectWriter()
> {}
>
> +void X86ELFObjectWriter::WriteEFlags() {
> + unsigned EFlags = 0;
> + switch (TargetObjectWriter->getOSType()) {
> + case Triple::NativeClient: EFlags |= ELF::EF_NACL_ALIGN_32; break;
> + default: break;
> + }
> + Write32(EFlags);
>
>
> -bw
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nacl_elf_new.patch
Type: application/octet-stream
Size: 3316 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110909/bf611567/attachment.obj>
More information about the llvm-commits
mailing list