compiling with 2.95
Hi,
I have downloaded grub 2 from cvs and tried to compile it on my system which is a debian woody with gcc version 2.95.4
It is written in the INSTALL file that the required version is * GCC 2.95 or later.
It didn't work for 3 reasons:
1) unnamed union
2) declaration not at the beginning of a block
3) undefined symbol (memset)
Although I don't know if you are interrested in that or not, I'm sending
some modifications about these three items that allows grub 2 to be
compiled with 2.95.4 (at least on my system).
I'm not used to send patches so I might be doing something wrong, please tell me if it is the case.
fs/ext2.c +8 -6
@@ -136,7 +136,9 @@grub_uint32_t tripple_indir_block; } blocks;char symlink[60 ]; - }; + } osd1_union; +#define ext2_blocks osd1_union.blocks +#define ext2_symlink osd1_union.symlinkgrub_uint32_t version;grub_uint32_t acl;grub_uint32_t dir_acl;
@@ -199,14 +201,14 @@/* Direct blocks. */ if (fileblock <INDIRECT_BLOCKS ) - blknr =grub_le_to_cpu32 (inode->blocks.dir_blocks[fileblock]); + blknr =grub_le_to_cpu32 (inode->ext2_blocks.dir_blocks[fileblock]);/* Indirect. */ else if (fileblock <INDIRECT_BLOCKS + blksz /4 ) {grub_uint32_t indir[blksz /4 ];if (grub_disk_read (data->disk, -grub_le_to_cpu32 (inode->blocks.indir_block) +grub_le_to_cpu32 (inode->ext2_blocks.indir_block) << log2_blksz,0 , blksz, (char *) indir))return grub_errno;
@@ -222,7 +224,7 @@grub_uint32_t indir[blksz /4 ];if (grub_disk_read (data->disk, -grub_le_to_cpu32 (inode->blocks.double_indir_block) +grub_le_to_cpu32 (inode->ext2_blocks.double_indir_block) << log2_blksz,0 , blksz, (char *) indir))return grub_errno;
@@ -361,7 +363,7 @@otherwise it is stored in the inode. */ if (grub_le_to_cpu32 (diro->inode.size) <=60 )grub_strncpy (symlink, - diro->inode.symlink, + diro->inode.ext2_symlink,grub_le_to_cpu32 (diro->inode.size));else {
@@ -548,7 +550,7 @@ grub_ext2_dir (grub_device_t device, const char *path, int (*hook) (const char *filename, int dir)) { - struct grub_ext2_data *data = 0;; + struct grub_ext2_data *data = 0;struct grub_fshelp_node *fdiro =0 ; auto int NESTED_FUNC_ATTR iterate (const char *filename,
fs/hfs.c +8 -11
@@ -480,6 +480,7 @@/* Iterate over all records in this node. */ for (i =0 ; i <grub_be_to_cpu16 (node.node.reccnt); i++) { +struct grub_hfs_record rec;int pos = (nodesize >>1 ) -1 - i;struct pointer {
@@ -489,14 +490,10 @@ pnt = (struct pointer *) (grub_be_to_cpu16 (node.offsets[pos]) + node.rawnode); -struct grub_hfs_record rec = - { - &pnt->key, - pnt->keylen, - &pnt->key + pnt->keylen +(pnt->keylen +1 ) %2 , - nodesize -grub_be_to_cpu16 (node.offsets[pos]) - - pnt->keylen -1 - }; + rec.key = &pnt->key; + rec.keylen = pnt->keylen; + rec.data = &pnt->key + pnt->keylen +(pnt->keylen +1 ) %2 ; + rec.datalen = nodesize -grub_be_to_cpu16 (node.offsets[pos]) - pnt->keylen -1 ;if (node_hook (&node.node, &rec))return 0 ;
@@ -590,8 +587,8 @@struct grub_hfs_catalog_key key = {0 ,grub_cpu_to_be32 (dir),0 ,"" }; autoint node_found (struct grub_hfs_node *,struct grub_hfs_record *); - autoint it_dir (struct grub_hfs_node * __attribute ((unused)), -struct grub_hfs_record *); +//auto int it_dir (struct grub_hfs_node * __attribute ((unused)), + autoint it_dir (struct grub_hfs_node * ,struct grub_hfs_record *);int node_found (struct grub_hfs_node *hnd,struct grub_hfs_record *rec)
@@ -658,6 +655,7 @@char *origpath;struct grub_hfs_filerec frec;struct grub_hfs_dirrec *dir = (struct grub_hfs_dirrec *) &frec; +struct grub_hfs_catalog_key key; frec.type =GRUB_HFS_FILETYPE_DIR ;if (path[0 ] !='/' )
@@ -689,7 +687,6 @@ next++; } -struct grub_hfs_catalog_key key; key.parent_dir =grub_cpu_to_be32 (inode); key.strlen =grub_strlen (path);
fs/iso9660.c +1 -1
@@ -509,7 +509,7 @@int nameoffset = offset +sizeof (dirent);struct grub_fshelp_node *node;int sua_off = (sizeof (dirent) + dirent.namelen +1 - - (dirent.namelen %2 ));; + - (dirent.namelen %2 ));int sua_size = dirent.len - sua_off; sua_off += offset + dir->data->susp_skip;
fs/jfs.c +11 -8
@@ -194,7 +194,10 @@grub_uint8_t unused[32 ];grub_uint8_t path[128 ]; } symlink; - } __attribute__ ((packed)); + } jfs_union __attribute__ ((packed)); +#define jfs_file jfs_union.file +#define jfs_dir jfs_union.dir +#define jfs_symlink jfs_union.symlink } __attribute__ ((packed));struct grub_jfs_data
@@ -289,7 +292,7 @@return -1 ; } -return getblk (&inode->file.tree, &inode->file.extents[0 ]); +return getblk (&inode->jfs_file.tree, &inode->jfs_file.extents[0 ]); }
@@ -376,7 +379,7 @@struct grub_jfs_diropen *diro;int blk; - de = (struct grub_jfs_internal_dirent *) inode->dir.dirents; + de = (struct grub_jfs_internal_dirent *) inode->jfs_dir.dirents;if (!((grub_le_to_cpu32 (inode->mode) &GRUB_JFS_FILETYPE_MASK ) ==GRUB_JFS_FILETYPE_DIR ))
@@ -394,12 +397,12 @@ diro->inode = inode;/* Check if the entire tree is contained within the inode. */ -if (inode->file.tree.flags &GRUB_JFS_TREE_LEAF ) +if (inode->jfs_file.tree.flags &GRUB_JFS_TREE_LEAF ) { - diro->leaf = inode->dir.dirents; + diro->leaf = inode->jfs_dir.dirents; diro->next_leaf = (struct grub_jfs_leaf_next_dirent *) de; - diro->sorted = inode->dir.header.sorted; - diro->count = inode->dir.header.count; + diro->sorted = inode->jfs_dir.header.sorted; + diro->count = inode->jfs_dir.header.count; diro->dirpage =0 ;return diro;
@@ -412,7 +415,7 @@return 0 ; } - blk =grub_le_to_cpu32 (de[inode->dir.header.sorted[0 ]].ex.blk2); + blk =grub_le_to_cpu32 (de[inode->jfs_dir.header.sorted[0 ]].ex.blk2); blk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz) -
GRUB_DISK_SECTOR_BITS);
/* Read in the nodes until we are on the leaf node level. */
@@ -481,7 +484,7 @@
/* If the inode contains the entrie tree or if this was the last
node, there is nothing to read. */
- if ((diro->inode->file.tree.flags & GRUB_JFS_TREE_LEAF)
+ if ((diro->inode->jfs_file.tree.flags & GRUB_JFS_TREE_LEAF)
|| !grub_le_to_cpu64 (diro->dirpage->header.nextb))
return GRUB_ERR_OUT_OF_RANGE;
@@ -703,7 +706,7 @@
return grub_error (GRUB_ERR_SYMLINK_LOOP, "too deep nesting of
symlinks");
if (size <= 128)
- grub_strncpy (symlink, data->currinode.symlink.path, 128);
+ grub_strncpy (symlink, data->currinode.jfs_symlink.path, 128);
else if (grub_jfs_read_file (data, 0, 0, size, symlink) < 0)
return grub_errno;
fs/minix.c +1 -1
@@ -252,7 +252,7 @@struct grub_minix_sblock *sblock = &data->sblock;/* Block in which the inode is stored. */ -int block; +int block,offs; data->ino = ino;/* The first inode in minix is inode 1. */
@@ -265,7 +265,7 @@if (data->version ==1 ) { block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct
grub_minix_inode));
- int offs = (ino % (GRUB_DISK_SECTOR_SIZE
+ offs = (ino % (GRUB_DISK_SECTOR_SIZE
/ sizeof (struct grub_minix_inode))
* sizeof (struct grub_minix_inode));
@@ -276,7 +276,7 @@
{
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix2_inode));
- int offs = (ino
+ offs = (ino
% (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix2_inode))
* sizeof (struct grub_minix2_inode));
fs/ufs.c +12 -10
@@ -45,17 +45,17 @@#define UFS_BLKSZ (sblock) (grub_le_to_cpu32 (sblock->bsize))#define INODE (data,field) (data->ufs_type == UFS1 ? \ - data->inode. field : data->inode2. field) + data->ufs_inode.ufs_inode_union. field : data->ufs_inode2.ufs_inode_union. field)#define INODE_ENDIAN (data,field,bits1,bits2) (data->ufs_type == UFS1 ? \ - grub_le_to_cpu##bits1 (data->inode.field) : \ - grub_le_to_cpu##bits2 (data->inode2.field)) + grub_le_to_cpu##bits1 (data->ufs_inode.field) : \ + grub_le_to_cpu##bits2 (data->ufs_inode2.field))#define INODE_SIZE (data) INODE_ENDIAN (data,size,32,64)#define INODE_MODE (data) INODE_ENDIAN (data,mode,16,16)#define INODE_BLKSZ (data) (data->ufs_type == UFS1 ? 32 : 64)#define INODE_DIRBLOCKS (data,blk) INODE_ENDIAN \ - (data,blocks.dir_blocks[blk],32,64) + (data,ufs_inode_union.blocks.dir_blocks[blk],32,64)#define INODE_INDIRBLOCKS (data,blk) INODE_ENDIAN \ - (data,blocks.indir_blocks[blk],32,64) + (data,ufs_inode_union.blocks.indir_blocks[blk],32,64)/* The blocks on which the superblock can be found. */ static int sblocklist[] = {128 ,16 ,0 ,512 ,-1 };
@@ -112,7 +112,7 @@grub_uint32_t indir_blocks[GRUB_UFS_INDIRBLKS ]; } blocks;grub_uint8_t symlink[(GRUB_UFS_DIRBLKS +GRUB_UFS_INDIRBLKS ) *4 ]; - }; + } ufs_inode_union;grub_uint32_t flags;grub_uint32_t nblocks;grub_uint32_t gen;
@@ -151,7 +151,7 @@grub_uint64_t indir_blocks[GRUB_UFS_INDIRBLKS ]; } blocks;grub_uint8_t symlink[(GRUB_UFS_DIRBLKS +GRUB_UFS_INDIRBLKS ) *8 ]; - }; + } ufs_inode_union;grub_uint8_t unused[24 ]; };
@@ -174,7 +174,9 @@ {struct grub_ufs_inode inode;struct grub_ufs2_inode inode2; - }; + } ufs_data_union ; +#define ufs_inode ufs_data_union.inode +#define ufs_inode2 ufs_data_union.inode2enum {UFS1 ,
@@ -323,7 +325,7 @@if (data->ufs_type ==UFS1 ) { -struct grub_ufs_inode *inode = &data->inode; +struct grub_ufs_inode *inode = &data->ufs_inode; grub_disk_read (data->disk, (((grub_le_to_cpu32 (sblock->inoblk_offs) + grpblk)
@@ -335,7 +337,7 @@ }else { -struct grub_ufs2_inode *inode = &data->inode2; +struct grub_ufs2_inode *inode = &data->ufs_inode2; grub_disk_read (data->disk, (((grub_le_to_cpu32 (sblock->inoblk_offs) + grpblk)
include/grub/misc.h +1 -0
@@ -35,6 +35,7 @@char *EXPORT_FUNC (grub_stpcpy ) (char *dest,const char *src);char *EXPORT_FUNC (grub_strcat ) (char *dest,const char *src);char *EXPORT_FUNC (grub_strncat ) (char *dest,const char *src,int c); +void *EXPORT_FUNC (memset ) (void *s,int c,grub_size_t n);/* Prototypes for aliases. */ void *EXPORT_FUNC (memmove ) (void *dest,const void *src,grub_size_t n);
Signature · 6 lines
Vincent Guffens PhD Student UCL/CESAME tel: +32 10 47 80 30 Value your freedom, or you will lose it, teaches history. "Don't bother us with politics," respond those who don't want to learn. -- Richard M. Stallman
Quoted 3 lines · Vincent Guffens
1) unnamed union
2) declaration not at the beginning of a block
3) undefined symbol (memset)
I see.
Quoted 3 lines
Although I don't know if you are interrested in that or not, I'm sending some modifications about these three items that allows grub 2 to be compiled with 2.95.4 (at least on my system).
Your patch is definitely useful. But I'm not sure about unnamed union... It is not so convenient to specify union names. I think the code was written by Marco, so I'd like to hear his opinion about this.
Quoted 2 lines
I'm not used to send patches so I might be doing something wrong, please tell me if it is the case.
Please write ChangeLog.
Okuji
Quoted 7 lines · Yoshinori K. Okuji
Quoted 3 lines
Although I don't know if you are interrested in that or not, I'm sending some modifications about these three items that allows grub 2 to be compiled with 2.95.4 (at least on my system).
Your patch is definitely useful. But I'm not sure about unnamed union... It is not so convenient to specify union names. I think the code was written by Marco, so I'd like to hear his opinion about this.
This weekend I will have a look at this. I had the feeling it should've worked with gcc 2.95, but I never tried it myself. Hopefully I can find some box with gcc 2.95... In the weekend I will try to do some other hacking as well.
Thanks,
Marco
Quoted 7 lines · Marco Gerards
Quoted 4 lines · Yoshinori K. Okuji
Quoted 3 lines
Although I don't know if you are interrested in that or not, I'm sending some modifications about these three items that allows grub 2 to be compiled with 2.95.4 (at least on my system).
Quoted 7 lines
Quoted 1 line
Your patch is definitely useful. But I'm not sure about unnamed union... It is not so convenient to specify union names. I think the code was written by Marco, so I'd like to hear his opinion about this.
This weekend I will have a look at this. I had the feeling it should've worked with gcc 2.95, but I never tried it myself. Hopefully I can find some box with gcc 2.95... In the weekend I will try to do some other hacking as well.
I had a look in google about unnamed unions and I have seen some references about them with 2.95 but I was not able to compile with them. Maybe there is a gcc switch for them ?
Also, when compiling with an "old" system, there is this sed error message:
sed: -e expression #1, char 69: Extra characters after command
the sed version is:
$ sed -V GNU sed version 3.02
so I have also replaced in gencmdlist.sh the following line:
#grep -v "^#" | sed -ne "/grub_register_command *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $module/;p}"
grep -v "^#" | grep -e "grub_register_command *( *\"" | sed -ne "s/.*grub_register_command *( *\"\([^,\"]*\).*/\1: $module/;p"
Signature · 6 lines
Vincent Guffens PhD Student UCL/CESAME tel: +32 10 47 80 30 Value your freedom, or you will lose it, teaches history. "Don't bother us with politics," respond those who don't want to learn. -- Richard M. Stallman
Quoted 3 lines · Vincent Guffens
I had a look in google about unnamed unions and I have seen some references about them with 2.95 but I was not able to compile with them. Maybe there is a gcc switch for them ?
I have no idea.
Quoted 8 lines
Also, when compiling with an "old" system, there is this sed error message:
sed: -e expression #1, char 69: Extra characters after command
the sed version is:
$ sed -V GNU sed version 3.02
Quoted 6 lines
so I have also replaced in
gencmdlist.shthe following line:#grep -v "^#" | sed -ne "/grub_register_command *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $module/;p}"
grep -v "^#" | grep -e "grub_register_command*( *\"" | sed -ne "s/.*grub_register_command *( *\"\([^,\"]*\).*/\1: $module/;p"
Oh, really? This is a very standard sed expression, I think. Ummh... What should I do?
Okuji
[...]
Quoted 10 lines
Quoted 6 lines
so I have also replaced in
gencmdlist.shthe following line:#grep -v "^#" | sed -ne "/grub_register_command *( *\"/{s/.*( *\"\([^\"]*\)\".*/\1: $module/;p}"
grep -v "^#" | grep -e "grub_register_command*( *\"" | sed -ne "s/.*grub_register_command *( *\"\([^,\"]*\).*/\1: $module/;p"Oh, really? This is a very standard sed expression, I think. Ummh... What should I do?
It looks like the problem comes from the braces in the expression, if I try a simple one like this:
$ cat test | sed -e "/grub_register/{s/register/test/;p}"
sed: -e expression #1, char 35: Extra characters after commandSo I split the expression in two parts. From my understanding of it, the following is equivalent to the original sed expression:
grep -v "^#" | grep -e "grub_register_command *( *\"" | sed -ne "s/.*( *\"\([^\"]*\)\".*/\1: $module/;p"
which is not the same line than the one I sent in the previous mail (although they give the same command.lst)
Signature · 6 lines
Vincent Guffens PhD Student UCL/CESAME tel: +32 10 47 80 30 Value your freedom, or you will lose it, teaches history. "Don't bother us with politics," respond those who don't want to learn. -- Richard M. Stallman