elf: eagerly resovle PLT entries in mlocked object

If an object needs to be locked in memory, because, for example, part
of its code is executed with preemption disabled it usually also needs
an eager resolution of PLT entries.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: fail early when resolving PLT with preemption disabled

Lazy resolution of PLT entries involves some actions that require
enabled preemption (e.g. acquiring a mutex, allocating/freeing memory).
Calling elf_resolve_pltgot() with preemption disabled, despite being
incorrect, often does not causes any aborts or other catastrophic failures
when using a "normal" build. That's, however, not the case when debug
allocator or any other form of non-contiguous memory allocation is used.
Adding an assert would help catching such errors early and avoid bug
reports like "abort in elf_resolve_pltgot when OSv is low on memory" once
large memory allocator is able to postpone oom by falling back to
non-contiguous memory mappings.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Ensure plain_transport::close does not throw

IFF other side shuts down early, the previous code would throw
an exception, which of course was not handled -> termination
handler -> httpserver exit. Most likely not what we want.

Signed-off-by: Calle Wilund <calle@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
console: fix support for discarding or keeping input

When switching the tty to raw mode, we have two options about what to
do with the unread input, including perhaps an partially edited line:

1. Keep the the partially edited line and make it available for reading
   imediately (it can never be edited again, even if we later go back to
   cooked mode).
   This happens with TCSETS ioctl, or tcsetattr's TCSANOW option.

2. Discard all unread input, including a partial edited line.
   This happens with TCSETSF ioctl, or tcsetattr's TCSAFLUSH option.

Unfortunately, we supported neither of these two options correctly...
Instead, what we did in both cases was to "hide" the partially edited
line for the duration of the raw mode, and "bring it back" when going
back to cooked mode. This is *not* how Linux behaves, and caused problems
in one application which tried to switch to raw mode after input was
already available.

So this patch fixes these two cases to each do the right thing.
We add to the line-discipling object two new operations - take_pending_input
(copying the partially edited line into the ready-to-read buffer),
and discard_pending_input (discarding both partially edited line and the
ready-to-read buffer). We then call these two new operations as appropriate
from the ioctl operations of the console device.

Fixes #461

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>