D
D
DVoropaev2019-08-03 13:19:16
GCC
DVoropaev, 2019-08-03 13:19:16

Why does assembler code (GNU assembler) compile on one machine but not on another?

.hello_str:
  .string	"Hello, GAS!"
  .globl	main
  .type	main, @function
main:
  movl	$.hello_str, %edi
  call	[email protected]
  movl	$0, %edi
  call	[email protected]

I compile like this:
gcc -o a.out ./1_1.s
Both machines have 64bit ubunta.
On one it compiles, on the other it fails.
gcc -o a.out ./1_1.s
/usr/bin/ld: /tmp/ccTxc4Ax.o: relocation R_X86_64_32 against `.text' can not be used when making a PIE object; перекомпилируйте с параметром -fPIC
/usr/bin/ld: final link failed: Раздел, непредставимый для вывода
collect2: error: ld returned 1 exit status

-fPIC option doesn't help
$ gcc -fPIC -o a.out ./1_1.s
/usr/bin/ld: /tmp/ccbz8Upi.o: relocation R_X86_64_32 against `.text' can not be used when making a PIE object; перекомпилируйте с параметром -fPIC
/usr/bin/ld: final link failed: Раздел, непредставимый для вывода
collect2: error: ld returned 1 exit status

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tutuborg, 2019-08-03
@tutuborg

Compare the list and versions of installed software.

J
jcmvbkbc, 2019-08-03
@jcmvbkbc

$ gcc -fPIC -o a.out ./1_1.s
The -fPIC option doesn't help

DVoropaev You already had such a question, the answer has not changed since then: it -fPICchanges the assembler output of the compiler, this key does not affect the finished assembler file in any way.
This code is 32-bit, compile it with the -m32.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question