Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!motcsd!hpda!hpcuhc!hpsemc!jmorris From: jmorris@hpsemc.HP.COM (John V. Morris) Newsgroups: comp.sys.hp Subject: Re: 9000/835 loader and assembler problems Message-ID: <1250033@hpsemc.HP.COM> Date: 6 Jun 89 21:19:55 GMT References: <14870@comp.vuw.ac.nz> Organization: HP Technology Access Center, Cupertino, CA Lines: 106 Unlike most lds, the 835 linker loads multiple modules from a single file. Thus, if you append extra stuff at the end of an object file, the 835 linker thinks there is another module present and attempts to load it. The workaround is fairly simple. You have to add a valid object module header in front of the extra stuff. I've attached a program that shows how to do it. Coincidently, the header is is 128 bytes long. Concerning the address rounding. I believe the addresses are rounded in order to support load on demand and shared code. There ought to be a way to turn it off, but I don't know how to do it. Does the -N option help? John Morris HP Technology Access Center (415) 725-3871 ---------------------------- dummy_som.c ----------------------------- /********************************************************************* dummy_som file >>object.o dummy_som creates a Standard Object Module (SOM) containing the given file. The dummy SOM can be appended to a conventional object file and will be ignored by the linker. This program is useful for applications that wish to append their own data to object files. Written for the HP 9000 S800 at the HP Technology Access Center. **********************************************************************/ #include #include #include #include main(argc, argv) /******************************************************************** dummy_som creates a null Standard Object Module containing the given file ************************************************************************/ char **argv; { struct header hdr; struct stat file_status; char buffer[8192]; int fd, len; /* get the arguments */ if (argc<2) {perror("usage: dummy_som file >> obj.o"); exit(1); } /* open the file to append to header */ fd = open(argv[1], O_RDONLY); if (fd < 0) {perror("dummy_som: Can't open input file"); exit(1);} /* get information about the file */ if (fstat(fd, &file_status) < 0) {perror("dummy_som: Can't get status of input file"); exit(1);} /* create a dummy header that reserves the extra space */ memset(&hdr, 0, sizeof(hdr)); hdr.system_id = HP9000S800_ID; hdr.version_id = VERSION_ID; hdr.a_magic = RELOC_MAGIC; hdr.som_length = sizeof(hdr) + file_status.st_size; hdr.checksum = compute_checksum(&hdr); /* output the dummy headr */ write(1, &hdr, sizeof(hdr)); /* append the data file to the header */ while ((len=read(fd, buffer, sizeof(buffer))) > 0) write(1, buffer, len); return 0; } compute_checksum(hdr) /**************************************************************** compute_checksum calculates the checksum of an object module header ******************************************************************/ struct header *hdr; { int sum, *ptr, i; /* start at beginning of header */ sum = 0; ptr = (int *)hdr; /* add up the checksum */ for (i = 0; i