[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    help with nasm or yasm on amd64?
From:       "Jeremy C. Reed" <reed () reedmedia ! net>
Date:       2010-04-07 16:45:08
Message-ID: alpine.NEB.2.01.1004071107300.424 () t1 ! m ! reedmedia ! net
[Download RAW message or body]

I am hoping someone here has experience with using a non-gas assembler 
on amd64. If not I will talk to yasm or nasm lists instead ...

Using latest pcc from cvs on a NetBSD/amd64 system.

I built using configure --with-assembler=/usr/pkg/bin/yasm 

Then after install, I set CC to my new pcc for running configure again 
(to build with pcc instead of my system's cc). config.log showed a lot 
of warnings and errors, apparently from yasm.

/tmp/ctm.06667a:1: redefinition of `.text'
/tmp/ctm.06667a:1: warning: no non-local label before `.text'
/tmp/ctm.06667a:2: instruction expected after label
/tmp/ctm.06667a:2: warning: no non-local label before `.align'
/tmp/ctm.06667a:3: warning: no non-local label before `.globl'
/tmp/ctm.06667a:3: instruction expected after label
/tmp/ctm.06667a:4: warning: no non-local label before `.type'
/tmp/ctm.06667a:4: instruction expected after label
/tmp/ctm.06667a:4: warning: ignoring unrecognized character `@'
/tmp/ctm.06667a:6: instruction expected after label
/tmp/ctm.06667a:6: warning: `rbp' is a register in 64-bit mode
/tmp/ctm.06667a:7: expression syntax error
/tmp/ctm.06667a:7: warning: `rsp' is a register in 64-bit mode
/tmp/ctm.06667a:7: warning: `rbp' is a register in 64-bit mode
/tmp/ctm.06667a:8: instruction expected after label
/tmp/ctm.06667a:8: warning: `rsp' is a register in 64-bit mode
/tmp/ctm.06667a:11: instruction expected after label
/tmp/ctm.06667a:11: warning: `rbp' is a register in 64-bit mode
/tmp/ctm.06667a:14: redefinition of `movl'
/tmp/ctm.06667a:11: `movl' previously defined here
/tmp/ctm.06667a:14: warning: `rbp' is a register in 64-bit mode
/tmp/ctm.06667a:17: instruction expected after label
/tmp/ctm.06667a:17: warning: ignoring unrecognized character `.'
/tmp/ctm.06667a:18: instruction expected after label

So I tried with --with-assembler=/usr/pkg/bin/nasm (using system's cc) 
and installed and tried again. This time config.log showed different 
warnings and errors -- this time from nasm.

/tmp/ctm.09593a:1: warning: label alone on a line without a colon might 
be in error
/tmp/ctm.09593a:1: error: attempt to define a local label before any 
non-local labels
/tmp/ctm.09593a:2: error: attempt to define a local label before any 
non-local labels
/tmp/ctm.09593a:2: error: parser: instruction expected
/tmp/ctm.09593a:3: error: attempt to define a local label before any 
non-local labels
/tmp/ctm.09593a:3: error: parser: instruction expected
/tmp/ctm.09593a:4: error: attempt to define a local label before any 
non-local labels
/tmp/ctm.09593a:4: error: parser: instruction expected
/tmp/ctm.09593a:6: error: parser: instruction expected
/tmp/ctm.09593a:7: error: expression syntax error
/tmp/ctm.09593a:8: error: parser: instruction expected
/tmp/ctm.09593a:11: error: parser: instruction expected
/tmp/ctm.09593a:14: error: symbol `movl' redefined
/tmp/ctm.09593a:14: error: parser: instruction expected
/tmp/ctm.09593a:17: error: parser: instruction expected
/tmp/ctm.09593a:18: error: parser: instruction expected
/tmp/ctm.09593a:19: warning: label alone on a line without a colon might 
be in error

The configure generated C code that compiles but fails to assemble 
with nasm or yasm is:

/* confdefs.h.  */
#define PACKAGE_NAME "pcc"
#define PACKAGE_TARNAME "pcc"
#define PACKAGE_VERSION "0.9.9"
#define PACKAGE_STRING "pcc 0.9.9"
#define PACKAGE_BUGREPORT "<pcc-list@ludd.ltu.se>"
#define TARGET_LITTLE_ENDIAN 1
#define ELFABI
#define ASSEMBLER "/usr/pkg/bin/yasm"
#define WCHAR_TYPE UNSIGNED
#define WCHAR_SIZE 4
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}

(Only change is ASSEMBLER when chose nasm instead.)

I also tried pcc building src/bin/cat:

  t1:cat$ /home/reed/opt/pcc/bin/pcc -S cat.c
  cat.c, line 42: warning: unsupported attribute '__used__'

"as" which is GNU assembler 2.16.1 works:

  t1:cat$ as -o cat.o cat.s
  t1:cat$ file cat.s cat.o
  cat.s: ASCII assembler program text
  cat.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

But neither yasm nor "yasm -p gas" nor nasm work -- many errors and 
warnings similar to above.

Any ideas on using nasm or yasm?

My next step is linking it. I tried (a.out made by gas):

 $  ld -o cat -X -d -e __start -dynamic-linker /usr/libexec/ld.elf_so \
 /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o cat.o \
 -L/home/reed/opt/pcc/lib/pcc/x86_64-unknown-netbsd4.99.62/0.9.9/lib/ \
 -lc /usr/lib/crtend.o /usr/lib/crtn.o

(By the way, 
/home/reed/opt/pcc/lib/pcc/x86_64-unknown-netbsd4.99.62/0.9.9/lib is 
empty.)

Any suggestions for different linker (with command-line syntax for 
this)? (I think the answer for this part is no.)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic