Bug 61144 - [4.9/4.10 Regression] Invalid optimizations for extern vars with local weak definitions

This applies the patch presented by Rich Felker in this
bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61144

The most notable victim of this bug is musl libc,
where flushes to stdout are misoptmised away.

Be aware that this patch haven't been applied to mainline,
and they might seek an other solution to this problem.
or1k: Add support for using the native atomics.

This adds support for the __sync and __atomics builtins for 1, 2 and 4
bytes of memory. Since the native instructions only protect a full word,
use 4 bytes where possible.
Revert 35f3c9f

The functions added in 35f3c9f for basic atomic functions are
superseeded by the native implementation in 3b695d1.
or1k: Hint that we will write to bval for CAS

Before this patch GCC would think that bval wouldn't be overwritten
which made the result comparision hilariously wrong when optimization
was turned up.
remove mismerges from upstream sync with 4.9.0
or1k/libgcc: make internal calls to __udivsi3 hidden

This way, the relocations can be resolved at link time and
there will be no R_OR1K_INSN_REL_26 relocs in libgcc_s.so.
or1k: define ASM_PREFERRED_EH_DATA_FORMAT

By defining ASM_PREFERRED_EH_DATA to DW_EH_PE_pcrel when
compiling with -fPIC, unaligned R_OR1K_32 relocs in .eh_frame
are avoided.