1

From Learning Linux Binary Analysis by Ryan "elfmaster" O'Neill. On Page 32, the author states,

The relocation records for 32-bit ELF files are the same as for 64-bit, but use 32-bit integers. The following example for are object file code will be compiled as 32-bit so that we can demonstrate implicit addends, which are not as commonly used in 64-bit. An implicit addend occurs when the relocation records are stored in ElfN_Rel type structures that don't contain an r_addend field and therefore the addend is stored in the relocation target itself. The 64-bit executables tend to use the ElfN_Rela structs that contain an explicit addend. I think it is worth understanding both scenarios, but implicit addends are a little more confusing, so it makes sense to bring light to this area.

What is the actual definition of an "addend"?

2
2

I think it just means "a number that's added", and in this case "the number that's added to the base load address (or segment load address) to compute the final pointer for this relocation".

Let's imagine that when we load our binary into memory at 0x400000 we have a pointer at 0x401234 that points to 0x405678. (If instead we loaded the binary at 0x800000 then this should point to 0x805678, hence it needs relocating.) I don't know ELF, but my reading of this is that

  • in the implicit case the relocation table stores just offsets into your binary, in this case 0x1234, and in our binary at offset 0x1234 we store the target offset 0x5678. Therefore relocation becomes

    for each address A in the relocation table *(base + A) += base

    (This is how relocation tables work in PE files.)

  • in the explicit case, the relocation table stores both the offset into your binary and the target offset, i.e. 0x1234 0x5678. So relocation here is

    for each address pair A, B in the relocation table *(base + A) = base + B

    I don't know what goes in the binary at offset 0x1234 in this case.

2
  • Augend is a term that means a number that is subject to addition
  • Addend is the number that you will be adding.

From Dictionary.com,

Have you ever found yourself staring at a piece of paper with “3 + 4” written on it, and wondered ‘what is the proper term for each of these two respective quantities?’ No? The first number is the augend and the number that is added to it is the addend.

You can see a chart of other math terms here on Wikipedia's "Calculation results",

Calculation results

Why the special terms here?

  • Well, that's likely because in assembly add rbi, rax will actually store the result in rbi. So knowing the first argument is not just an argument to add but the destination; add rax, rbi will store the result in rax. If assembly was displayed with operators instead, we'd have rbi += rax and rax += rbi.
  • Because the addend is not always an offset, and the augend is not always the base. Though in this specific example, "offset" is far more appropriate.
  • In this specific case, the term "implicit offset" can be found in the Tool Interface Standard (TIS) Executable and Linking Format (ELF) Specification Version 1.2,

    ... only Elf32_Rela entries contain an explicit addend. Entries of type Elf32_Rel store an implicit addend in the location to be modified. Depending on the processor architecture, one form or the other might be necessary or more convenient. Consequently, an implementation for a particular machine may use one form exclusively or either form depending on context.

1

Addend is simply "a number to be added to another", according to Merian Webster.

1
  • 1
    It was already stated in the existing answer. You could add a bit more to your answer to make it more informative. – Paweł Łukasik Mar 12 '19 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.