Hi all,

I am trying to combine multiple object files into a single relocatable object file using mspgcc (gcc version 3.2.3), and seems to encounter an error in the addend field of a relocation entry in the output file. I wonder if anyone has run into this problem and can kindly offer some advice. Following are the details.

Thanks.

Martin


I have two .c files: m.c calling a function defined in add2.c
---------------------------------------------------------------
> cat m.c
#include <stdio.h>

extern int add2(int);
int main()
{
  int a=5;
  printf("m: a=%d, calling add2()\n",a); // (A)
  a = add2(a);
  printf("m: returned from add2(), a=%d\n",a); // (B)
  return 0;
}
---------------------------------------------------------------
> cat add2.c
#include <stdio.h>

int add2(int n) {
  printf("add2: input=%d\n", n); // (C)
  return n + 2;
}
---------------------------------------------------------------
> msp430-gcc -Wall -Os -c m.c -o m.o
> msp430-gcc -Wall -Os -c add2.c -o add2.o
> msp430-ld -r --unresolved-symbols=ignore-in-object-files --strip-all -o m.cm m.o add2.o
> readelf -r m.cm

Relocation section '.rela.text' at offset 0x260 contains 9 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
0000003a  00000d05 R_MSP430_16_BYTE  00000280   __stack + 0
*00000042  00000105 R_MSP430_16_BYTE  00000000   .text + 0* (A)
00000046  00000905 R_MSP430_16_BYTE  00000000   printf + 0
0000004e  00000e05 R_MSP430_16_BYTE  00000072   add2 + 0
*00000054  00000105 R_MSP430_16_BYTE  00000000   .text + 19***(B)
00000058  00000905 R_MSP430_16_BYTE  00000000   printf + 0
00000060  00000b03 R_MSP430_16       00000000   __stop_progExec__ + 0
*0000007a  00000105 R_MSP430_16_BYTE  00000000   .text + 0***(C)
0000007e  00000905 R_MSP430_16_BYTE  00000000   printf + 0

Listing above shows in *bold* the relocation entries corresponding to the printf statments in m.c (A, B) and add2.c (C). Note that the arguments to the printf statements in m.c (A,B) are relocated with the correct addends, but argument to the printf statement in add2.c (C) erroneously gets a zero addend causing it to print the same argument as (A). hexdump of m.cm confirms that the addend field of the .rela type entry of (C) is indeed wrong and equal zero.







------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to