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

Georg-Johann Lay avr@gjlay.de
Thu Apr 26 18:11:00 GMT 2012


Georg-Johann Lay wrote:
> 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?

Hi, this is an updated patch that handles the new RELOCs in
gas/config/tc-avr.c:md_apply_fix()

        case BFD_RELOC_AVR_8_LO:
          *where = 0xff & value;
          break;

        case BFD_RELOC_AVR_8_HI:
          *where = 0xff & (value >> 8);
          break;

        case BFD_RELOC_AVR_8_HHI:
          *where = 0xff & (value >> 16);
          break;

> Up to now, I have no GPL copyright assignment on file.
> I requested the paperwork from FSF

I sent back the papers to the FSF and hope the paperwork it finished soon.

Johann

bfd/
	PR 13503
	* 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/
	PR 13503
	* 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.
	(md_apply_fix): Handle BFD_RELOC_AVR_8_LO, BFD_RELOC_AVR_8_HI,
	BFD_RELOC_AVR_8_HHI.
	
include/
	PR 13503
	* 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: 10835 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20120426/55524fad/attachment.bin>


More information about the Binutils mailing list