On Tue, 14 Aug 2007, Brian Dessent wrote: > PRC wrote: > > > I'm studying the ELF specfication version 1.1 recently. > > I'm confused about the 'addend' which is used in relocation. There > > doesn't seems to be explict descriptions about 'addend' in the > > specification. Can somebody make detailed explainations about how to > > calculate the value of the 'addend' when relocating an executable. > > > Each architecture defines its own set of R_<arch> relocations, each with > its own definition, so you can't really deduce anything from the generic > spec. True. Btwn, your question appears to me as the purpose of addend other than as "constant" added to get the relocated value. It manifests itself during segment relocations - generally speaking. Incase thats not at all what you meant, you can happily ignore the example. For e.g : R_386_PC32 2 word32 S + A - P This is a pc-relative relocation. S - symbol value, A - addend, P - PC value (location counter value) This says the efffective value is calculated by S + A - P Now as to A, this is computed by linker based on segment relocation If S is 100 in data section with base address as 1000 , P is 200 in text section with base as 0, S - P suffices if there is no data segement relocation(or text). However if data segment gets relocated to 2000, A will be 1000. The example maynot be precise, but I hope you get some picture. > > Brian > -- Regards, Anitha B @S A N K H Y A