linker: changes to init work arounds

Change three things regarding the work around to the fact that init is
special:

1) Only first stage init is special, so we change the check to include
   accessing /proc/self/exe, which if is available, means that we're
   not first stage init and do not need any work arounds.
2) Fix the fact that /init may be a symlink and may need readlink()
3) Suppress errors from realpath_fd() since these are expected to fail
   due to /proc not being mounted.

Bug: 80395578
Test: sailfish boots without the audit generated from calling stat()
      on /init and without the errors from realpath_fd()

Change-Id: I266f1486b142cb9a41ec791eba74122bdf38cf12
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 8bf4c94..741d4e0 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -551,9 +551,9 @@
   uint8_t* first = align_up(mmap_ptr, align);
   uint8_t* last = align_down(mmap_ptr + mmap_size, align) - size;
 
-  // arc4random* is not available in init because /dev/urandom hasn't yet been
+  // arc4random* is not available in first stage init because /dev/urandom hasn't yet been
   // created. Don't randomize then.
-  size_t n = is_init() ? 0 : arc4random_uniform((last - first) / PAGE_SIZE + 1);
+  size_t n = is_first_stage_init() ? 0 : arc4random_uniform((last - first) / PAGE_SIZE + 1);
   uint8_t* start = first + n * PAGE_SIZE;
   munmap(mmap_ptr, start - mmap_ptr);
   munmap(start + size, mmap_ptr + mmap_size - (start + size));