fusfu / shellinabox

Automatically exported from code.google.com/p/shellinabox
Other
0 stars 0 forks source link

Compile Shellinabox on AIX fails with object file foremat #140

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm trying to compile Shell In A Box for AIX 7.1 on Power 7 and am running into 
some trouble with the objcopy from the resource files (for instance the html 
and javascript files). The makefile is running the below commands to create 
object files from the resource files:

  objcopy shellinabox/cgi_root.html shellinabox/cgi_root.o
  objcopy shellinabox/root_page.html shellinabox/root_page.o
  objcopy shellinabox/vt100.js shellinabox/vt100.o
  objcopy shellinabox/shell_in_a_box.js shellinabox/shell_in_a_box.o
  objcopy shellinabox/styles.css shellinabox/styles.o
  objcopy shellinabox/print-styles.css shellinabox/print-styles.o
  objcopy shellinabox/enabled.gif shellinabox/enabled.o
  objcopy shellinabox/favicon.ico shellinabox/favicon.o
  objcopy shellinabox/beep.wav shellinabox/beep.o
When the makefile attempts to create the final shellinaboxd output file by 
combining the object files, collect2 fails because the resource files do not 
have the proper object file format:

  collect2: shellinabox/cgi_root.o: not a COFF file
I have attempted to manually reformat the object files for these resources 
using the objcopy command and specifying the proper input and output formats 
(or what I presume are the correct input and output formats!) to no avail.

  objcopy -I binary -O aixcoff-rs6000 -B power shellinabox/root_page.html shellinabox/root_page.o
After performing this step for each resource file, the make will no longer 
complain about the object file format. However, the linker is now complaining 
about symbol tables in the object files as shown below. There are multiple 
errors per object file.

  ld: 0711-562 SEVERE ERROR: Symbol table entry 0 in object shellinabox/cgi_root.o:
        An auxiliary symbol table entry is required for a
        C_EXT or C_HIDEXT entry.
Have you seen anything similar to this issue before? Is there any further 
information you can give on how to copy the resource files properly (or make 
the linker disregard the error)? Alternatively, would it be possible to allow 
shellinabox to use the resource files directly instead of compiling them into 
the final executable (preferably as a configure option)?

Regards,

Mike

Original issue reported on code.google.com by reinhol...@gmail.com on 29 Sep 2011 at 3:28

GoogleCodeExporter commented 9 years ago
Hi,

I have some further information on what the issue seems to be on AIX. AIX uses 
the XCOFF binary format instead of ELF. As a result, it looks like the symbols 
being referenced by your program are specific to ELF object files. I'm doing 
some research right now to find out how to add the necessary symbols to the 
auxiliary symbol table. Alternatively, I may try to compile SIAB with some 
minor modifications to the symbol names. 

Regards,

Mike

Original comment by reinhol...@gmail.com on 30 Sep 2011 at 12:55

GoogleCodeExporter commented 9 years ago
Ok, I've done some further testing. The first piece that I have identified is 
that the Makefile does not have a case specified for Power / AIX. I added the 
following line in the objcopyflags to the makefile in order to get the objcopy 
to create the correct output file.

{{{
    rs6000)   echo '-O aixcoff-rs6000 -B power -v';;        \
}}}

Additionally, the symbols created by the objcopy on AIX seem to be prefixed 
with _binary_shellinabox_ instead of _binary_. I have attempted to adjust the 
symbol rename parameter from

{{{
  -e 's/^/--redefine-sym _binary_/'                           \
}}}

to

{{{
  -e 's/^/--redefine-sym _binary_shellinabox_/'                           \
}}}

However, when I view the contents of the object files which are the result of 
the objcopy command, the symbol names in the COFF symbol table at the end of 
the file still have the full object name.

I'm doing additional research to see if I can identify the cause of this.

Regards,

Mike

Original comment by reinhol...@gmail.com on 30 Sep 2011 at 3:33

GoogleCodeExporter commented 9 years ago
Hi,

After some further testing, I found that the changes to the objcopy command 
were unnecessary. The object files created by objcopy now have the proper 
symbols exported. Unfortunately, I am still running into an issue with the 
severe linker error. I believe that this is due to the AIX linker having 
tighter symbol table requirements than the GNU linker. I am currently working 
with IBM support and the AIX community to see if there is a resolution from 
that end. In the meantime, is there anything else that you can do from your end 
to assist with the compilation? Alternatively, would it be possibly to create a 
build which does not require these resources to be built in to the executable? 
This build would have to read in the resource files into the storage allocated 
by the program instead of copying from the compiled resources. If you would be 
willing to make this version of Shell In a Box, I would be most appreciative. 
If you are unable to for any reason, I may try to do so myself (although, this 
will probably take longer than if you were to do so) and then submit it back to 
you for your review. 

Regards,

Mike

Original comment by reinhol...@gmail.com on 3 Oct 2011 at 1:14

GoogleCodeExporter commented 9 years ago
I suspect that this is the same problem we've seen on other platforms.  The 
autotools have been updated and should fix build problems like this.

Original comment by beewoo...@gmail.com on 31 Mar 2012 at 10:50