The OpenGL ES 2.0 spec is a bit vague about glAttachShader, only saying it is the same as desktop OpenGL 2. So, reading the desktop OpenGL spec, I find in section 2.15.2:

Multiple shader objects of the same type may be attached to a single program object, and a single shader object may be attached to more than one program object.
So lets say I have two fragment shader objects with the following code:

Shader 1:
Code :
uniform mediump float opacity;
mediump vec3 getColor();
void main(void) {
   gl_FragColor.rgb = getColor();
   gl_FragColor.a = opacity;

Shader 2:
Code :
mediump vec3 getColor() {
    return vec3(1.0, 1.0, 1.0);

I want to compile each of the shaders as seperate objects and combine them, together with a vertex shader, into a single program object. As far as I understand the spec, this should be possible. Have I missed something? I ask because on the PowerVR SGX, the second shader fails to compile as it doesn't have a main() function:

ERROR: main() function is missing.
ERROR: 1 compilation errors. No code generated.
How are you supposed to attach "Multiple shader objects of the same type" if they all need a main() function?