[ARM] Mixing rel/rela relocations

Hi,

I was looking at the ARM ABI docs(http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf) and they mention.

"A binary file may use REL or RELA relocations or a mixture of the two (but multiple relocations for the same
address must use only one type)."

Does LLVM emit rel/rela relocations with ARM ?

Any tests ?

Thanks

Shankar Easwaran

Hi,

I was looking at the ARM ABI docs(http://infocenter.arm.
com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf) and they mention.

"A binary file may use REL or RELA relocations or a mixture of the two
(but multiple relocations for the same
address must use only one type)."

Does LLVM emit rel/rela relocations with ARM ?

I hope not. Ew.

-eric

Hi Shankar,

Does LLVM emit rel/rela relocations with ARM ?

I believe we emit .rel for (32-bit) ARM. Hard-coded in ARMELFObjectWriter.cpp (“HasRelocationAddend”). It seems to be what most toolchains have settled on. AArch64 is .rela always in LLVM, in case it matters.

Any tests ?

Well there are tests of what we do, but obviously not of the full scope of functionality permitted by the ABI.

Cheers.

Tim.

Thanks a lot for the answers.

Mixing rela/rel will make it hard for the linker to handle(especially the lot of configurations in which the linker works - shared libraries/partial linking/dynamic linking etc ).

Thanks

Shankar Easwaran

    Hi,

    I was looking at the ARM ABI
    docs(http://infocenter.arm.__com/help/topic/com.arm.doc.__ihi0044e/IHI0044E_aaelf.pdf
    <http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf>)
    and they mention.

    "A binary file may use REL or RELA relocations or a mixture of the
    two (but multiple relocations for the same
    address must use only one type)."

    Does LLVM emit rel/rela relocations with ARM ?

I hope not. Ew.

The only reason this is Ew is that llvm has decided not to prepare for it. There shouldn't be a single rel/rela type for a given output. The one that works for the given situation for the given section should be used. The mechanism for handling both should not be complicated.

There are rules about relocation order and multiple relocations can operate on a single point in the binary. There is no reason a section of .rel relocations cannot operate alongside a section of .rela relocations.

Unfortunately I believe the single rel/rela type is part and parcel to gnu as well and I have resigned myself to going with the flow for now.

Jack

    Hi,

    I was looking at the ARM ABI
    docs(http://infocenter.arm.__com/help/topic/com.arm.doc.__
ihi0044e/IHI0044E_aaelf.pdf
    <http://infocenter.arm.com/help/topic/com.arm.doc.
ihi0044e/IHI0044E_aaelf.pdf>)

    and they mention.

    "A binary file may use REL or RELA relocations or a mixture of the
    two (but multiple relocations for the same
    address must use only one type)."

    Does LLVM emit rel/rela relocations with ARM ?

I hope not. Ew.

The only reason this is Ew is that llvm has decided not to prepare for it.
There shouldn't be a single rel/rela type for a given output. The one that
works for the given situation for the given section should be used. The
mechanism for handling both should not be complicated.

There are rules about relocation order and multiple relocations can
operate on a single point in the binary. There is no reason a section of
.rel relocations cannot operate alongside a section of .rela relocations.

True, however, I can think of no reasonable situation that you'd want to do
that. RELA has been around long enough that it's the default for just about
any ELF platform so the amount of legacy code is just someone not
implementing RELA as they should.

-eric

Is there a reason behind this, if the compiler doesit ? anything on performance ? It makes tools that operate on the object files bit rusty.

I would have preferred using RELA all over.

Thanks

Shankar Easwaran