bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gas/29655] s390x gas generates PC32DBL instead of PLT32DBL for func


From: rui314 at gmail dot com
Subject: [Bug gas/29655] s390x gas generates PC32DBL instead of PLT32DBL for function call
Date: Fri, 07 Oct 2022 12:31:00 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=29655

--- Comment #14 from Rui Ueyama <rui314 at gmail dot com> ---
The following bash script should demonstrate the issue better:

-----
cat <<EOF > libfoo.h
#ifndef __PIC__
#error "this file must be compiled with -fPIC"
#endif

typedef void Fn();
void fn1_public(void);
void call_callback(Fn *callback);
EOF

cat <<EOF > libfoo.c
#include "libfoo.h"
#include <stdio.h>

__attribute__((visibility("hidden")))
void fn1(void) { printf("fn1\n"); }

extern void fn1_public() __attribute__((alias("fn1")));

void call_callback(Fn *callback) {
  if (callback == fn1)
    printf("do something special here ...\n");
  callback();
}
EOF

cat <<EOF > main.c
#include "libfoo.h"

int main() {
  fn1_public();
  call_callback(fn1_public);
}
EOF

cc -fPIC -shared -o libfoo.so libfoo.c
cc -fPIC -c -o main.o main.c
cc -no-pie -o main main.o ./libfoo.so
./main
-----

On non-s390x machines, the above script print out "fn1 do something special
here ... fn1" while on s390x it prints out "fn1 fn1".

In this script, libfoo assumes that executables depending on the library don't
have canonical PLTs, and it "enforces" the restriction by "#ifdef __PIC__" in
the library header. I'm not arguing that that assumption is correct, but there
are code out there that does something like this. I also don't understand why
people would want to do this, but again, the above code compiles and "just
works" if it's not on s390x.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]