--- Comment #10 from Sergei Trofimovich <slyfox at inbox dot ru> ---
Oh, I have forgot to ask another question:

In attached reloc-bug.c there is seemingly two functionally identical samples:

  extern char glo_u64_middle_hidden[] __attribute__((visibility("hidden")));
  static u64 __attribute__((noinline)) val_u64_hidden(void) {
    const u64 * m = (const u64 *)glo_u64_middle_hidden;
    return m[-1];


  extern char glo_s_middle_hidden[] __attribute__((visibility("hidden")));
  struct s { u64 a; };
  static u64 __attribute__((noinline)) val_s_hidden(void) {
    const struct s * m = (const struct s *)glo_s_middle_hidden;
    return m[-1].a;

Why those are handled differently? First looks like it works, second does not.
It was my main signal to file a bug against gcc as asymmetry looked fishy.

$ ./reloc-bug
val/global = 100
val/hidden = 100
Segmentation fault

Reply via email to