Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARMv5 needs +strict-align #42314

Merged
merged 1 commit into from
Jun 1, 2017
Merged

ARMv5 needs +strict-align #42314

merged 1 commit into from
Jun 1, 2017

Commits on May 30, 2017

  1. ARMv5 needs +strict-align

    Without that flag, LLVM generates unaligned memory access instructions, which are not allowed on ARMv5.
    
    For example, the 'hello world' example from `cargo --new` failed with:
    ```
    $ ./hello
    Hello, world!
    thread 'main' panicked at 'assertion failed: end <= len', src/libcollections/vec.rs:1113
    note: Run with `RUST_BACKTRACE=1` for a backtrace.
    ```
    
    I traced this error back to the following assembler code in `BufWriter::flush_buf`:
    ```
        6f44:       e28d0018        add     r0, sp, rust-lang#24
    [...]
        6f54:       e280b005        add     fp, r0, rust-lang#5
    [...]
        7018:       e5cd001c        strb    r0, [sp, rust-lang#28]
        701c:       e1a0082a        lsr     r0, sl, rust-lang#16
        7020:       03a01001        moveq   r1, rust-lang#1
        7024:       e5cb0002        strb    r0, [fp, rust-lang#2]
        7028:       e1cba0b0        strh    sl, [fp]
    ```
    
    Note that `fp` points to `sp + 29`, so the three `str*`-instructions should fill up a 32bit - value at `sp + 28`, which is later used as the value `n` in `Ok(n) => written += n`. This doesn't work on ARMv5 as the `strh` can't write to the unaligned contents of `fp`, so the upper bits of `n` won't get cleared, leading to the assertion failure in Vec::drain.
    
    With `+strict-align`, the code works as expected.
    jannic authored May 30, 2017
    Configuration menu
    Copy the full SHA
    4450807 View commit details
    Browse the repository at this point in the history