tkchia / gcc-ia16

Fork of Lambertsen & Jenner (& al.)'s IA-16 (Intel 16-bit x86) port of GNU compilers ― added far pointers & more • use https://github.com/tkchia/build-ia16 to build • Ubuntu binaries at https://launchpad.net/%7Etkchia/+archive/ubuntu/build-ia16/ • DJGPP/MS-DOS binaries at https://gitlab.com/tkchia/build-ia16/-/releases • mirror of https://gitlab.com/tkchia/gcc-ia16
GNU General Public License v2.0
179 stars 13 forks source link

Assembly listing output does not interleave C code into the listing, probably due to "target system does not support debug output" #105

Open ecm-pushbx opened 2 years ago

ecm-pushbx commented 2 years ago

Setting up gcc to create an (Intel syntax) assembly listing file allows to request "a high-level language listing", though it is written that -g needs to be specified for this. Most of the parameters needed for that I took from https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_2.html#SEC10 plus the =file specifier listed in https://astro.uni-bonn.de/~sysstw/CompMan/gnu/as.html

However, trying this with gcc-ia16 outputs a warning that reads cc1: warning: target system does not support debug and does not include any high-level language listing.

Here's a test case:

$ cat hello.c

#include "stdio.h"

void main(void) {
        printf("Hello world!\n");
}
$ gcc -o hello hello.c -g -Wa,-anlhd=hello.lst,-L -masm=intel
$ cat hello.lst
   1                            .file   "hello.c"
   2                            .intel_syntax noprefix
   3                            .text
   4                    .Ltext0:
   5                            .section        .rodata
   6                    .LC0:
   7 0000 48656C6C              .string "Hello world!"
   7      6F20776F
   7      726C6421
   7      00
   8                            .text
   9                            .globl  main
  11                    main:
  12                    .LFB0:
  13                            .file 1 "hello.c"
   1:hello.c       ****
   2:hello.c       **** #include "stdio.h"
   3:hello.c       ****
   4:hello.c       **** void main(void) {
  14                            .loc 1 4 17
  15                            .cfi_startproc
  16 0000 55                    push    rbp
  17                            .cfi_def_cfa_offset 16
  18                            .cfi_offset 6, -16
  19 0001 4889E5                mov     rbp, rsp
  20                            .cfi_def_cfa_register 6
   5:hello.c       ****         printf("Hello world!\n");
  21                            .loc 1 5 2
  22 0004 488D3D00              lea     rdi, .LC0[rip]
  22      000000
  23 000b E8000000              call    puts@PLT
  23      00
   6:hello.c       **** }
  24                            .loc 1 6 1
  25 0010 90                    nop
  26 0011 5D                    pop     rbp
  27                            .cfi_def_cfa 7, 8
  28 0012 C3                    ret
  29                            .cfi_endproc
  30                    .LFE0:
  32                    .Letext0:
$ ia16-elf-gcc -o hello.com hello.c -g -Wa,-anlhd=hello.lst,-L -masm=intel
cc1: warning: target system does not support debug output
$ cat hello.lst
   1                            .arch i8086,jumps
   2                            .code16
   3                            .intel_syntax noprefix
   4                    #NO_APP
   5                            .section        .rodata
   6                    .LC0:
   7 0000 48656C6C              .string "Hello world!"
   7      6F20776F
   7      726C6421
   7      00
   8                            .text
   9                            .global main
  11                    main:
  12 0000 55                    push    bp
  13 0001 89E5                  mov     bp,     sp
  14 0003 B80000                mov     ax,     offset .LC0
  15 0006 50                    push    ax
  16 0007 16                    push    ss
  17 0008 1F                    pop     ds
  18 0009 E8FEFF                call    puts
  19 000c 83C402                add     sp,     2
  20 000f 90                    nop
  21 0010 5D                    pop     bp
  22 0011 16                    push    ss
  23 0012 1F                    pop     ds
  24 0013 C3                    ret
  26                            .ident  "GCC: (GNU) 6.3.0"
$
asiekierka commented 2 years ago

Most likely a duplicate of https://github.com/tkchia/gcc-ia16/issues/38 .