Page 1 of 1

what is __guard?

Posted: Mon Apr 06, 2009 7:52 pm
by earlz
Hi, I recently ran into a problem. I implemented strlcpy and was testing using only pcc; I have no problems with it. Whenever I compile with gcc however, I get a linker error: : undefined reference to `__guard'

The code that causes it is this:

Code: Select all

file_handle_t f;

.. the struct:
typedef uint32_t (*read_type_t)(struct fs_node*,uint32_t off,uint32_t len,uint8_t* buffer);
typedef uint32_t (*write_type_t)(struct fs_node*,uint32_t off,uint32_t len,uint8_t* buffer);
//typedef struct dirent * (*readdir_type_t)(struct fs_node*,uint32_t index);
typedef struct fs_node * (*finddir_type_t)(struct fs_node*,char *name); 
typedef int (*close_type_t)(struct fs_node*);

typedef struct{
	uint32_t type;
	uint32_t mask;
	uint32_t uid;
	uint32_t gid;
}file_flags_t;

typedef struct {
	read_type_t read;
	write_type_t write;
	close_type_t close;
	uint32_t (*get_size)(struct fs_node*);
}fs_file_func;

typedef struct {
	int (*get_node)(struct fs_node*,char *name,uint32_t uid,uint32_t gid,struct fs_node* buffer);
	int (*readdir)(struct fs_node*,uint32_t index,struct fs_node* buf);
	int (*remove_node)(struct fs_node* node); //the file must not be open.
	int (*new_symlink)(struct fs_node*,char* from,char *to, uint32_t uid,uint32_t gid);
	int (*new_node)(struct fs_node*,char *name,file_flags_t *type,struct fs_node* new_file);
	//in new_node, new_file is optional. It is ignored if NULL. else gives 
	//the new file node.
	  //get_node from here only works on single deep nodes, it doesn't follow directories.
}fs_dir_func;

typedef struct{
	close_type_t close;
	int (*open)(struct fs_node*,uint32_t uid,uint32_t gid,uint32_t mode);
	int (*read_symlink)(struct fs_node*,char *string_buffer);
	int (*read_flags)(struct fs_node*,file_flags_t* buffer);
	int (*write_flags)(struct fs_node*,file_flags_t* source);
	int (*lock)(struct fs_node*);
	int (*unlock)(struct fs_node*);
	//lock and unlock can not be used if the file is not open by the current process.
}fs_common_func;

typedef struct fs_node{
	char name[256];     // The filename.(not including path)
	uint32_t inode;       // This is device-specific - provides a way for a filesystem to identify files..
	uint32_t impl;        // An implementation-defined number.
	fs_file_func *file; //function pointer struct to avoid redundancy.
	fs_dir_func *dir;
	fs_common_func f;
	struct mount_node *mp;
} file_handle_t;

typedef struct mount_node{
	char name[256];
	char dev_device[16]; //the /dev/* device, or 0 length if it doesn't use a /dev device.
	uint32_t flags;
	int (*get_node)(char *name,uint32_t uid,uint32_t gid,file_handle_t* buffer);
}mount_handle_t;


struct dirent 
{
  char name[256]; // Filename.
  uint32_t inode;     // Inode number. Required by POSIX.
};
Does anyone have any idea what this __guard function does?
Also, my CFLAGS are CFLAGS= -nostdlib -nostartfiles -nodefaultlibs -I ./include -fno-builtin

Re: what is __guard?

Posted: Mon Apr 06, 2009 8:39 pm
by JohnnyTheDon
From this page, it looks like it may have to do with a stack protector.

Try -ffreestanding.

Re: what is __guard?

Posted: Tue Apr 07, 2009 12:54 am
by neonek
Look here.

Re: what is __guard?

Posted: Tue Apr 07, 2009 3:45 am
by pcmattman
From this page, it looks like it may have to do with a stack protector.
-fno-stack-protector.

And really, a quick search in the wiki before posting could've saved having to post this altogether.