2017-05-01 15 views
1

a Rust compiler bug in the AVR backend을 해결하기 위해 필자는 #[inline(always)]으로 많은 함수를 표시했습니다. 더 이상 문제에 부딪치지 않습니다.적극적인 인라이닝을 사용하여 "재배치가 잘리는"재배치가 실패합니다.

그러나, 이러한 주석을 현재 연결은 relocation truncated to fit 많은 메시지와 함께 실패합니다

target/avr-atmega328p/release/deps/chip8_avr-41c427b8d446a439.o: In function `LBB5_18': 
chip8_avr.cgu-0.rs:(.text.main+0x432): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
target/avr-atmega328p/release/deps/chip8_avr-41c427b8d446a439.o: In function `LBB5_23': 
chip8_avr.cgu-0.rs:(.text.main+0x45c): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
target/avr-atmega328p/release/deps/chip8_avr-41c427b8d446a439.o: In function `LBB5_31': 
chip8_avr.cgu-0.rs:(.text.main+0x4ae): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
target/avr-atmega328p/release/deps/chip8_avr-41c427b8d446a439.o: In function `LBB5_34': 
chip8_avr.cgu-0.rs:(.text.main+0x4d2): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
target/avr-atmega328p/release/deps/chip8_avr-41c427b8d446a439.o: In function `LBB5_146': 
chip8_avr.cgu-0.rs:(.text.main+0x58a): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
chip8_avr.cgu-0.rs:(.text.main+0x58e): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
chip8_avr.cgu-0.rs:(.text.main+0x592): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
target/avr-atmega328p/release/deps/chip8_avr-41c427b8d446a439.o: In function `LBB5_153': 
chip8_avr.cgu-0.rs:(.text.main+0x59a): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
chip8_avr.cgu-0.rs:(.text.main+0x59e): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
chip8_avr.cgu-0.rs:(.text.main+0x5a6): relocation truncated to fit: R_AVR_7_PCREL against `no symbol' 
chip8_avr.cgu-0.rs:(.text.main+0x5aa): additional relocation overflows omitted from the output 
collect2: error: ld returned 1 exit status 

This SO answer

큰 내 기능 점프는 컴파일러가 준비해야 할 것이 있음을 의미한다. Rust와 동일한 설정은 무엇입니까?

답변

0

디스 어셈블리를 충분히 자세히 살펴본 후에는 이러한 재배치 대상이 모두 (짧은) 점프가 아닌 분기 명령의 오프셋에 있음을 알 수 있습니다. 예 : 는 0x08에서 :

00000000 <_ZN12chip8_engine7opcodes6decode17haab3c6c935229a6aE>: 
    0: e8 2f   mov  r30, r24 
    2: f9 2f   mov  r31, r25 
    4: 80 e0   ldi  r24, 0x00  ; 0 
    6: 61 30   cpi  r22, 0x01  ; 1 
    8: 01 f4   brne .+0    ; 0xa <_ZN12chip8_engine7opcodes6decode17haab3c6c935229a6aE+0xa> 
    a: 81 83   std  Z+1, r24  ; 0x01 
    c: 82 83   std  Z+2, r24  ; 0x02 
    e: 81 e0   ldi  r24, 0x01  ; 1 

00000010 <LBB0_2>: 
    10: 80 83   st  Z, r24 
    12: 08 95   ret 

현재 다음에서 그들을 채우기 위해 링커를 사용하려고 충분한 함수의 경우, 빈 (.+0) 오프셋 이러한 지점을 생성하는 녹 컴파일러의 AVR 포크, 이러한 내부 기능을 오프셋 할 수 있습니다. 단일 분기 명령어에 적합한 것보다 커집니다.

AVR 포크 오브 루스트에 reported this as a compiler bug이 있습니다. 한 가지 가능한 해결책은 오프셋이 맞지 않는 경우를 위해 링커에서 2 단계 분기 (점프로의 분기)를 생성하도록하는 것이 었습니다. 다른 하나는 링커를 전혀 사용하지 않는 것입니다. 문제의 분기가 내부 함수이므로 관련 주소는 컴파일 타임에 알려 져야하므로 필요한 경우 2 단계 분기를 생성 할 수 있습니다.