Bug 11297 - Support for 8-bit relocations for AVR architecture
Summary: Support for 8-bit relocations for AVR architecture
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-18 21:00 UTC by Andrew Zabolotny
Modified: 2012-10-21 17:42 UTC (History)
1 user (show)

See Also:
Host:
Target: avr-linux-gnu
Build:
Last reconfirmed:


Attachments
The patch against binutils 2.18 (1.01 KB, patch)
2010-02-18 21:01 UTC, Andrew Zabolotny
Details | Diff
A simple testcase demonstrating the AVR binutils limitation (70 bytes, text/plain)
2010-02-18 21:02 UTC, Andrew Zabolotny
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Zabolotny 2010-02-18 21:00:35 UTC
Until today the implementation of binutils for the AVR architecture did not
support 8-bit relocations. This means that constructs like counted strings:

.byte 2f-1f
1: .ascii "blah"
2:

were impossible, because GAS would tell me "illegal relocation size: 1". The
above example works fine on almost every other supported architecture.

The attached patch implements support for BFD_RELOC_8 relocation type in
binutils, and for the respective R_AVR_8 relocation type in avr-elf32. Both
relocations that are resolved at assembly time as well as link-time applied
relocations work.

Also attaching a simple testcase which should assemle fine with the patch
applied, and will emit two errors without the patch applied.
Comment 1 Andrew Zabolotny 2010-02-18 21:01:29 UTC
Created attachment 4609 [details]
The patch against binutils 2.18

The patch is against latest stable binutils for AVR, hopefully it should apply
without much hassle on later versions.
Comment 2 Andrew Zabolotny 2010-02-18 21:02:19 UTC
Created attachment 4610 [details]
A simple testcase demonstrating the AVR binutils limitation
Comment 4 Nick Clifton 2010-02-23 11:42:05 UTC
Hi Andrew,

  Thanks for reporting this problem, and for providing the fix.  I have checked
your patch into the mainline sources along with these changelog entries.

Cheers
  Nick

gas/ChangeLog
	PR binutils/11297
	* config/tc-avr.c (md_apply_fix): Handle BFD_RELOC_8.
	(avr_cons_fix_new): Handle fixups of a single byte.

bfd/ChangeLog
	PR binutils/11297
	* elf32-avr.c (elf_avr_howto_table): Add R_AVR_8.
	(avr_reloc_map): Map BFD_RELOC_8 to R_AVR_8.

include/elf/ChangeLog
	PR binutils/11297
	* avr.h: (R_AVR_8): New relocation number.
Comment 5 Andrew Zabolotny 2012-10-21 16:53:14 UTC
A regression happened: this patch was broken by one of later patches.

If you try the testcase attached to this ticket, it'll bring the good old error messages:

[zap@zap|~]avr-as test.S 
test.S: Assembler messages:
test.S:1: Error: illegal relocation size: 1
test.S:6: Error: illegal relocation size: 1

[zap@zap|~]avr-as --version
GNU assembler (GNU Binutils) 2.20
Comment 6 Andrew Zabolotny 2012-10-21 17:42:28 UTC
Heck, that's not a binutils regression, it's a fedora package regression: up to Fedora 16 the binutils package was version 2.21, in Fedora 17 it downgraded to 2.20.
Sorry for noise :-(