[Patch,AVR]: PR13503: Add expression modifiers/RELOCs for data.

Georg-Johann Lay avr@gjlay.de
Tue Apr 24 21:06:00 GMT 2012


This patch adds new expression modifiers for 1-byte data
to get sub-bytes of byte addresses like in:

.byte lo8(expr)
.byte hi8(expr)
.byte hhi8(expr)
.byte hh8(expr)

The semantics of these new modifiers is the same as the semantics of
respective modifiers that are already allowed in instruction operands.
hh8 is just an alias for hhi8.

These modifiers are needed to support the __memx address space of avr-gcc:

extern const __memx char foo;
const __memx void *pfoo = &foo;

&foo and pfoo are 24-bit values.
Currently, avr-gcc emits an assembler warning for the code above to
hint that the feature is not supported by binutils.


This is my first patch to binutils so I am unsure about its completeness
and correctness; in particular:

* I don't understand the documentation of 'dst_mask' and 'pcrel_offset'
  from ./bfd/reloc.c and if their initialization in the new HOWTOs in
  ./bfd/elf32-avr.c is correct.

* If there is anything missing, like extra processing in
  ./gas/config/tc-avr.c:md_apply_fix() or in other places.
  Or does it work out of the box by HOWTO descriptions?

Up to now, I have no GPL copyright assignment on file.
I requested the paperwork from FSF and hope it will not take
as long as with GCC, which was about 1 1/2 years.

Johann

bfd/
	* reloc.c: Add new ENUM for BFD_RELOC_AVR_8_LO,
	BFD_RELOC_AVR_8_HI, BFD_RELOC_AVR_8_HHI.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenrate.
	* elf32-avr.c (elf_avr_howto_table): Add entries for
	R_AVR_8_LO8, R_AVR_8_HI8, R_AVR_8_HHI8.
	(avr_reloc_map): Add RELOC mappings for R_AVR_8_LO8, R_AVR_8_HI8,
	R_AVR_8_HHI8.

gas/
	* config/tc-avr.c (exp_mod_pm): Remove variable.
	(exp_mod_data_t): New typedef.
	(pexp_mod_data, exp_mod_data): New variables.
	(avr_parse_cons_expression): Scan through exp_mod_data[] to find
	data expression modifiers "pm", "gs", "lo8", hi8", "hhi8", "hh8"
	and set pexp_mod_data accordingly to be used in avr_cons_fix_new.
	(avr_cons_fix_new): Handle new data expression modifiers shipped
	in pexp_mod_data.

include/
	* elf/avr.h (RELOC_NUMBERS): Add values for R_AVR_8_LO8,
	R_AVR_8_HI8, R_AVR_8_HHI8.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin-data8-mod.diff
Type: text/x-patch
Size: 10330 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20120424/4d8a8125/attachment.bin>


More information about the Binutils mailing list