Need help with GNU assembler

How would one go about creating an .o file with ‘as’ that would be equivalent of creating one with gcc with -fPIC flag on amd64 arch?

I am getting this error:

/usr/bin/ld: temp/intmark.o: relocation R_X86_64_PC32 against symbol `malloc@@GLIBC_2.2.5’ can not be used when making a shared object; recompile with -fPIC

and this is the object:

$ objdump -r temp/intmark.o 

temp/intmark.o:     file format elf64-x86-64

RELOCATION RECORDS FOR [.text]:
OFFSET           TYPE              VALUE 
0000000000000013 R_X86_64_PC32     malloc-0x0000000000000004
0000000000000022 R_X86_64_PC32     gettimeofday-0x0000000000000004
00000000000003a9 R_X86_64_PC32     gettimeofday-0x0000000000000004
00000000000003b1 R_X86_64_PC32     free-0x0000000000000004
00000000000003f2 R_X86_64_PC32     malloc-0x0000000000000004
0000000000000420 R_X86_64_PC32     gettimeofday-0x0000000000000004
00000000000007a4 R_X86_64_PC32     gettimeofday-0x0000000000000004
00000000000007ac R_X86_64_PC32     free-0x0000000000000004

help

My only experience is with NASM. But it should get you on the right track.

nasm -f elf source.asm
ld -m elf_i386 -s -o executable source.o
./executable