I have searched far and wide for how to do this and have failed to come up with an answer.
My memory layout is as follows:
Fake Address | Section
I managed to solve it by calculating the size of the code by using the linker command: size. In my Makefile i set SIZE to the size of the code. I then call cpp (the preprocessor) to calculate all absolute addresses (using c-syntax). I then link using the generated linkfile: tmp.ld
%.elf: %.o
$(eval SIZE := $(shell arm-none-eabi-size -B $< | tail -n 1 | awk -F ' ' '{print $$1}'))
$(CC) -DSEG_SIZE=$(SIZE) -P -E -x c link.ld -o tmp.ld
$(CC) -o $@ $< $(LDFLAGS)
In the link.ld-file i can do all kinds of calculations (as SEG_SIZE is a constant):
#define SEG_LAST_ADDR 1234
#define MY_SEG (SEG_LAST_ADDR - SEG_SIZE)
MEMORY
{
bootloader (rx) : ORIGIN = MY_SEG, LENGTH = SEG_SIZE
...
}
I finally link against the tmp.ld-file.