Article View: gnu.gcc.help
Article #41409Obj-C and AIX 4.1 problem
From: Danny Sung
Date: Wed, 27 Mar 1996 00:00
Date: Wed, 27 Mar 1996 00:00
92 lines
3693 bytes
3693 bytes
I'm having a curious problem with Objective C under AIX 4.1. Well, I
was told that there was a bug in the current version of gcc we have
installed here (2.6.0) which prevented ObjC programs from linking
properly. I was also given a sample program that supposedly exemplifies
the problem, but unfortunately, I don't know ObjC. I thought I'd try
installing the gcc 2.7.0 to see if that would work, but it started to
look like it would be a lot of work, so I opted to try the test code
on my Linux system at home. And, well... it didn't work. It managed
to compile ok, but the program just seg-faulted around the
*ptr=strdup("hello world") call. Replacing it with *ptr="hello
world" worked fine, however. As far as I can tell (unless I'm just
missing something so incredibly obvious that I can't see it), there's
no reason the strdup shouldn't work. Maybe there's some objective-c
thing about it that I don't know, or maybe there's really a bug.
Anyway, I'd greatly appreciate any help you have to offer. Here's the
code:
-----------------------------------------------------------
// This is a simple hello-world style program for Objective C.
// Compile as "gcc -g objc-helloworld.m -lobjc"
// It's useful to test whether Objective C is working at all, in particular
// if the static constructors are being called.
// Another test of the linker can be tried by splitting this into three
// files: "HelloWorld.h", "HelloWorld.m" and "main.m" (following the
// comments) and try linking the two .o files together.
// "gcc -c -g main.m; gcc -c -g HelloWorld.m; gcc main.o HelloWorld.o -lobjc"
// this won't identify all possible objc-related linker problems, but might
// get one or two.
#import <objc/Object.h>
// HelloWorld.h
// #import <objc/Object.h>
@interface HelloWorld : Object {
char *output;
}
-init;
-print;
@end
// HelloWorld.m
// #import "HelloWorld.h"
@implementation HelloWorld
-init {
//output = (char *)strdup("Hello World!");
output = (char *)malloc(1024);
strcpy(output, "Hello World!");
}
-print {
puts(output);
}
@end
// main.m
// #import "HelloWorld.h"
int
main() {
id test;
test = [[HelloWorld alloc] init];
[test print];
return 0;
}
-----------------------------------------------------------
Here's a message regarding this that was forwarded through several
other people before it got to me, so I have no idea who the original
sender was:
> Unpack the patch, you'll see it's a patch to gcc itself - expr.c,
> the md, etc. I don't have high hopes that this patch will work, either.
>
> The fundamental problem with the AIX support can be traced down to the
> __builtin_apply stuff. If you're willing to get your hands dirty, you
> should read up on how gcc does that and see if you can make it work
> under AIX. It involves stack frame manipulation. As far as I
> understand, the AIX patch I gave you just kludges things to give some
> extra slop space to take care of not understood problems.
>
> If you're not willing to get your hands dirty, then you're going to
> have to wait until someone fixes it (indeterminate time), or else pay
> someone like Cygnus to make it work.
Thanks,
Danny Sung
dannys@ucla.edu
Technical Details
Message-ID:
<4ja1bt$9te@saba.info.ucla.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,cc1efac6ed10af50,start X-Google-Attributes: gid11318c,public From: dannys@PROBLEM_WITH_INEWS_DOMAIN_FILE (Danny Sung) Subject: Obj-C and AIX 4.1 problem Date: 1996/03/27 Message-ID: <4ja1bt$9te@saba.info.ucla.edu> X-Deja-AN: 144327001 organization: String to put in the Organization Header keywords: objc objective aix linux newsgroups: gnu.gcc.help