[PATCH] D28612: [ELF] - Added support for --emit-relocs.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 14:56:42 PST 2017


Rafael Avila de Espindola <rafael.espindola at gmail.com> writes:

> George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
>> I think we should just support that feature. 
>> It is specific, but not huge itself + looks stoned in linux kernel atm.
>> It is easier to support it than to force users to create workarounds. What do you think ?
>
> Maybe, but I do wonder why if they want a relocatable output they don't
> just use -r?

OK, I think I understand what they are doing:

* Link an executable. This causes the linker to resolve relocations
  assuming a given load address.
* Use --emit-relocs during the link.
* Post process the relocations and assume that all that will be needed
  at runtime is to add an offset.

The last part would not be true with -r as the linker would not apply
the relocations.

If designing this from scratch it seems the proper way to do it would be
to create a .so, but have a flag telling the linker to create regular
relocations for the .text sections instead of creating plts. That way
all that would be left would be the relocations that cannot be resolved
statically.

For now we should implement --emit-relocs as changing the existing
infrastructure to use something new would be quite a bit of work and
--emit-relocs doesn't look that bad.

Cheers,
Rafael


More information about the llvm-commits mailing list