[lld] r251526 - [ELF2] R_X86_64_COPY relocation implemented

Rafael Espíndola via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 07:16:36 PST 2015


> +  // Can have offset if requires copy relocation.
> +  uintX_t OffsetInBSS = 0;
> +  bool NeedsCopy = false;

You can drop the bool by initializing OffsetInBSS to -1 and using that
to mean that copy relocation is not needed, no?

> +    const Elf_Sym &Sym = C->Sym;
> +    // We don't know the exact alignment requirement for the data copied by a
> +    // copy relocation, so align that to 16 byte boundaries that should be large
> +    // enough unconditionally.
> +    Off = RoundUpToAlignment(Off, 16);
> +    C->OffsetInBSS = Off;
> +    Off += Sym.st_size;

The alignment of a symbol is less than or equal to the alignment of
the section it came from. You can use the alignment of the section in
here.

Cheers,
Rafael


More information about the llvm-commits mailing list