Relocations for PPC ELF
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    The number of different relocations that can be done on ppc elf files is daunting to me.

    I'm only interested in performing relocations for the purpose of recreating an executable program image so I'm hoping that a subset of those relocations is sufficient. Can anyone comment on this or point me to some practical guide on this topic?
    PPC assembly ain't so bad... ;)
  • »04.01.16 - 04:25
    Profile Visit Website
  • MorphOS Developer
    bigfoot
    Posts: 508 from 2003/4/11
    Not the most practical guide, but the relocations are documented in System V Application Binary Interface - PowerPC Processor Supplement.

    Off the top of my head, I'd say that for simple programs you will run into R_PPC_REL24 and R_PPC_REL14 for branches, R_PPC_ADDR32 for pointers in data and R_PPC_ADDR16_HA, R_PPC_ADDR16_HI and R_PPC_ADDR16_LO for building 32 bit addresses with PPC instructions.
    I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.
  • »04.01.16 - 06:17
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Thank you for your help.

    Out of more than 100 relocation types, those are the only ones I've implemented. After loading a number of program files I expected to get some 'unimplemented error messages' - but there's been none so far... I did find that the Cave Story executable seems to have a relocation pointing to a STN_UNDEF or null symbol... Not quite sure what that's about...
    PPC assembly ain't so bad... ;)
  • »09.01.16 - 10:40
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    That turned out to be an overflow bug... But I do note that another ELF resource I've been using has this to say about the r_info field of a relocation table entry:

    If the index is STN_UNDEF, the undefined symbol index, the relocation uses 0 as the ‘symbol value.’
    PPC assembly ain't so bad... ;)
  • »16.01.16 - 03:09
    Profile Visit Website