This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/11896] New: Internal compiler error using asm("lgdt %0\n\t"::"r" (gdtr));
- From: "earthpower at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Aug 2003 18:43:38 -0000
- Subject: [Bug c/11896] New: Internal compiler error using asm("lgdt %0\n\t"::"r" (gdtr));
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11896
Summary: Internal compiler error using asm("lgdt %0\n\t"::"r"
(gdtr));
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: earthpower at libero dot it
CC: gcc-bugs at gcc dot gnu dot org
gcc version 3.2.3
Reported:
- Output
- Src file
- File .i
gcc -c -fno-builtin -o kernel.o kernel.c -save-temps
kernel.c: In function `kernel_main':
kernel.c:94: warning: cast from pointer to integer of different size
kernel.c:96: Internal compiler error in emit_move_insn, at expr.c:2780
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.
make: *** [kernel.o] Error 1
kernel.c (note that elimating line 96 all works fine)
line 96: asm("lgdt %0\n\t"::"r" (gdtr));
#include "multiboot.h"
#include "io.h"
#include "memory.h"
#include "console.h"
#include "PM.h"
#define GDT_DIMENSION 100
/*
At this moment:
CS points to a code segment descriptor with base address 0 and limit 4 gig - 1
DS, SS, ES, FS, and GS point to a data segment descriptor with base address 0 and
limit 4 gig - 1
So it's like we are using falt addresses and so cs:B8000 becomes B8000
*/
//void kernel_main(word magic_number, struct MultibootInfo *mbi);
void panic(char * msg)
{
print_str("PANIC ");
print_str(msg);
}
void print_some_info(struct multiboot_info *mbi, dword magic_number)
{
init_video_memory_text();
clear_screen();
print_str("************************************\n");
print_str("____________RITE_OF_WOLF____________\n");
print_str("************************************\n\n");
if (sizeof(byte)!=1){
panic("Byte have wrong size");
return;
};
if (sizeof(word)!=2){
panic("Word have wrong size");
return;
};
if (sizeof(dword)!=4){
panic("Double word have wrong size");
return;
};
if (sizeof(qword)!=8){
panic("Quad word have wrong size");
print_number(sizeof(qword));
panic("Quad word have wrong size");
return;
};
if (magic_number == 0x2BADB002) {
print_str("* Loaded from a multiboot compliant boot loader\n");
} else {
print_str("* Not loaded from a multiboot compliant boot loader\n");
print_str(" Magic number retrieved : ");
print_hex(magic_number);
print_str("\n");
};
if (mbi->flags & 0x1){
print_str("* Memory info provided\n");
print_str(" Upper memory in KB : ");
print_number(mbi->mem_upper);
print_str("\n");
print_str(" Lower memory in KB : ");
print_number(mbi->mem_lower);
print_str("\n");
};
if (mbi->flags &010){
print_str("* Boot device info provided\n");
if (mbi->boot_device & 0x10000000){
print_str(" Booted from hard disk");
} else {
print_str(" Booted from floppy");
};
} else {
print_str("* Boot device info not provided\n");
};
}
kernel_main(struct multiboot_info *mbi, word magic_number)
{
GDTR gdtr;
segment_descriptor gdt[3];
init_video_memory_text();
clear_screen();
print_str("* Vecchia GDT (non valida)");
setup_gdt_entry(&gdt[0], 0, 0, 0, 0);
setup_gdt_entry(&gdt[1], 0x00101000, 0x00600000, ACS_CODE, 0);
setup_gdt_entry(&gdt[2], 0x00600000, 0x01500000, ACS_DATA, 0);
gdtr.address = (word)&gdt;
gdtr.size = sizeof(gdt)-1;
asm("lgdt %0\n\t"::"r" (gdtr));
/*__asm__ __volatile__ (
" lgdt (%0)\n\t"
: : "p" (gdtr) );
//gdt_updateSegments(4,8);
//print_str("* GDT valida!");*/
while (1);
}
kernel.i
# 1 "kernel.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "kernel.c"
# 1 "multiboot.h" 1
# 16 "multiboot.h"
# 1 "types.h" 1
typedef unsigned char byte;
typedef unsigned short int word;
typedef unsigned int dword;
typedef unsigned long long qword;
# 17 "multiboot.h" 2
typedef struct multiboot_header
{
dword magic;
dword flags;
dword checksum;
dword header_addr;
dword load_addr;
dword load_end_addr;
dword bss_end_addr;
dword entry_addr;
} multiboot_header_t;
typedef struct aout_symbol_table
{
dword tabsize;
dword strsize;
dword addr;
dword reserved;
} aout_symbol_table_t;
typedef struct elf_section_header_table
{
dword num;
dword size;
dword addr;
dword shndx;
} elf_section_header_table_t;
typedef struct multiboot_info
{
dword flags;
dword mem_lower;
dword mem_upper;
dword boot_device;
dword cmdline;
dword mods_count;
dword mods_addr;
union
{
aout_symbol_table_t aout_sym;
elf_section_header_table_t elf_sec;
} u;
dword mmap_length;
dword mmap_addr;
} multiboot_info_t;
typedef struct module
{
dword mod_start;
dword mod_end;
dword string;
dword reserved;
} module_t;
typedef struct memory_map
{
dword size;
dword base_addr_low;
dword base_addr_high;
dword length_low;
dword length_high;
dword type;
} memory_map_t;
# 2 "kernel.c" 2
# 1 "io.h" 1
inline byte inportb(word port);
inline void outportb(word port, byte value);
inline void outportw(word port, word value);
inline void disable_interrupts(void);
inline void enable_interrupts(void);
inline void disable_NMIs(void);
inline void enable_NMIs(void);
# 3 "kernel.c" 2
# 1 "memory.h" 1
void memset(void * ptr, byte value, unsigned long how_many);
void * memcpy(void * dst_ptr, const void * src_ptr, unsigned bytes_number);
# 4 "kernel.c" 2
# 1 "console.h" 1
void init_video_memory_text();
inline void set_cursor(byte x, byte y);
inline byte get_cursor_position_x();
inline byte get_cursor_position_y();
inline void move_cursor(unsigned char x_move, unsigned char y_move);
inline word get_cursor_position();
void clear_screen();
inline void print_char(char c);
inline void print_str(char * str);
inline void print_number(unsigned long number);
inline void print_hex(dword dw);
# 5 "kernel.c" 2
# 1 "PM.h" 1
# 89 "PM.h"
#pragma pack (push, 1)
typedef struct {
word limit_l;
word base_l;
byte base_m;
byte access;
byte limit_h_and_attribs;
byte base_h;
} segment_descriptor_struct;
typedef union {
segment_descriptor_struct structured;
dword raw;
} segment_descriptor;
typedef struct {
word size;
dword address;
} GDTR;
#pragma pack (pop)
void setup_gdt_entry(segment_descriptor *item, dword base, dword limit,
byte access, byte attribs);
void init_gdt();
# 6 "kernel.c" 2
# 24 "kernel.c"
void panic(char * msg)
{
print_str("PANIC ");
print_str(msg);
}
void print_some_info(struct multiboot_info *mbi, dword magic_number)
{
init_video_memory_text();
clear_screen();
print_str("************************************\n");
print_str("____________RITE_OF_WOLF____________\n");
print_str("************************************\n\n");
if (sizeof(byte)!=1){
panic("Byte have wrong size");
return;
};
if (sizeof(word)!=2){
panic("Word have wrong size");
return;
};
if (sizeof(dword)!=4){
panic("Double word have wrong size");
return;
};
if (sizeof(qword)!=8){
panic("Quad word have wrong size");
print_number(sizeof(qword));
panic("Quad word have wrong size");
return;
};
if (magic_number == 0x2BADB002) {
print_str("* Loaded from a multiboot compliant boot loader\n");
} else {
print_str("* Not loaded from a multiboot compliant boot loader\n");
print_str(" Magic number retrieved : ");
print_hex(magic_number);
print_str("\n");
};
if (mbi->flags & 0x1){
print_str("* Memory info provided\n");
print_str(" Upper memory in KB : ");
print_number(mbi->mem_upper);
print_str("\n");
print_str(" Lower memory in KB : ");
print_number(mbi->mem_lower);
print_str("\n");
};
if (mbi->flags &010){
print_str("* Boot device info provided\n");
if (mbi->boot_device & 0x10000000){
print_str(" Booted from hard disk");
} else {
print_str(" Booted from floppy");
};
} else {
print_str("* Boot device info not provided\n");
};
}
kernel_main(struct multiboot_info *mbi, word magic_number)
{
GDTR gdtr;
segment_descriptor gdt[3];
init_video_memory_text();
clear_screen();
print_str("* Vecchia GDT (non valida)");
setup_gdt_entry(&gdt[0], 0, 0, 0, 0);
setup_gdt_entry(&gdt[1], 0x00101000, 0x00600000, (0x80 | 0x18 | 0x02), 0);
setup_gdt_entry(&gdt[2], 0x00600000, 0x01500000, (0x80 | 0x10 | 0x02), 0);
gdtr.address = (word)&gdt;
gdtr.size = sizeof(gdt)-1;
asm("lgdt %0\n\t"::"r" (gdtr));
while (1);
}